Small Plugin Discussion (Unity version)

  • Hellow everyone, I know that Unity version plugins are not in the main priority at this moment and new API will probably appear only in one of latest beta releases, but I have some questions about them. Some of them were probably answered earlier, but some info may changed during time.


    So, my questions are:

    1. Will plugins have a system for custom objects?

    2. If yes how it will work? Will objects be loaded from some sort of unity assets or it will be possible to load models from formats like OBJ?

    3. Will it be possible to construct things in code procedurally or it will require manual model loading?

    4. Will models have support for different shaders or they will use single shader with different texture maps?

    5. Will game automatically store objects data in worlds database or each plugin should implement its own system to store objects?


    Answers on these questions are important for large plugins that can add custom stuff. For example if someone (me) want to add something like new biomes or resources into the game how much work it will require to store things in world and load them for each player? In Java version this can be done in a bit weird way (at least in example plugins), and plugins that will add massive amount of objects (like custom plants or world objects) require a lot of work and custom chunk management. If in Unity version this will be done on engine side (with some sort of object data serialisation method determined in plugin objects) it will make possible really huge things to be done (like custom biomes, flora, resources and so on). So, the most important question is actually the last one :)

  • 1. Will plugins have a system for custom objects?

    It depends: The old API only had a system to load custom models (through World3DModel class) and custom items (CustomItem class). It was possible for players to interact with custom models (and plugins could react on this interaction), but other than that, you couldn't make custom models behave like built-in objects (so it wasn't possible to create a custom chair, for example).

    Custom items, on the other hand, provided a bit more freedom in this regard, since they could behave like regular tools or melee weapons. Implementing more complex items (like firearms) was a bit difficult though.


    For the new API, we have plans to provide an easier way to create custom objects which behave like built-in objects (e.g. custom chairs, beds, chests etc). Same about plants and npcs in the long run.


    2. If yes how it will work? Will objects be loaded from some sort of unity assets or it will be possible to load models from formats like OBJ?

    You will definitely be able to load obj files, but probably we will also add support for Unity assets/prefabs ^^


    3. Will it be possible to construct things in code procedurally or it will require manual model loading?

    When talking about procedural construction, do you actually mean an API to create custom meshes (by providing individual vertices and indices)? If there is demand for such a feature, we could implement that :)


    4. Will models have support for different shaders or they will use single shader with different texture maps?

    Probably the game will provide a default lit and unlit shader for custom objects/models. Objects will require a single texture, however, we want to implement support for submeshes (so you can have separate textures per submesh). When it comes to custom plants (and other things like items or npcs), the game will probably use the same shader it already uses for built-in elements (so plants support wind and snowiness, for example).


    If you provide a Unity asset/prefab, it will probably also be possible to provide custom shaders/materials. However, the game uses Unitys HDRP, so it would be necessary to provide HDRP-compatible shaders in this case. Currently Unity doesn't provide surface shaders for HDRP, and authoring hand-written shaders for HDRP is extremely cumbersome, so the only "smooth" way atm would be to use shader graph.
    But this could also introduce compatibility issues: Unitys HDRP is still undergoing lots of changes, so there is always a chance that a newer Unity/HDRP version breaks old shaders/materials. So when providing custom materials/shaders, there is a chance they no longer work in a future RW version... ofc this doesn't happen when just providing raw obj files and textures.


    5. Will game automatically store objects data in worlds database or each plugin should implement its own system to store objects?

    It depends on how the elements will be loaded: When just loading a custom model, the game doesn't store it persistently, so the plugin would be responsible for storing it in a file or database. However, when creating a custom item/object/plant through the specific API, they will actually be stored in the world database when a player places them in the world, so there is no need for the plugin to implement custom serialization.


    When it comes to custom biomes: If a plugin alters the world generation, it will be necessary for the user to keep the plugin installed, otherwise the game will fallback to the default world generation once the plugin gets removed (which could result in messed up chunk borders if a custom world generation was used before). For custom objects or plants, it will also be necessary for the user to keep the plugin installed - otherwise the custom elements won't show up in the world anymore (they're still in the database though, so reinstalling the plugin will bring them back) ^^


    tl;dr Yes, when adding custom objects/plants/npcs etc, the game automatically stores them in the world database (when a player places a custom plant or object, or when a custom npc spawns) :D

  • Same about plants and npcs in the long run.

    Very cool 👍 I assume there will be animation support.

    create custom meshes (by providing individual vertices and indices)

    Sounds hardcore. Very hardcore. ^^

    However, when creating a custom item/object/plant through the specific API, they will actually be stored in the world database when a player places them in the world

    I assume by custom item/object/plant you mean the customization of an existing object? Like a sword or pickaxe with a different set of attributes as opposed to an entirely new item that includes a custom object?

  • When talking about procedural construction, do you actually mean an API to create custom meshes (by providing individual vertices and indices)? If there is demand for such a feature, we could implement that :)

    Yes, this is about custom vertices & indices handling. This is a very useful thing, especially for natural-looking objects and optimisation (when you can merge meshed into one to reduce render calls)

    Thank you for answer :)

  • Very cool 👍 I assume there will be animation support.

    Most likely yes, but it depends on whether or not we add support for Unity assets/prefabs - otherwise we don't have a pipeline to import animations at runtime (unless we add fbx support) ^^ I guess there will be support for Unity assets eventually, so we could enable support for Unitys "AnimationClip" (but that would mean you have to prepare them in Unity).


    But probably I can say more about that once we've added npcs to the new version :)


    I assume by custom item/object/plant you mean the customization of an existing object? Like a sword or pickaxe with a different set of attributes as opposed to an entirely new item that includes a custom object?

    Oh, actually I was refering to adding entirely new items :D Unlike static models (e.g. models loaded through World3DModel in the Java version), the game would store them persistently and treat them like built-in objects. For example, you could give a custom bed (which could have a custom model and texture) a "bed attribute", define a lying position etc. Similar to how CustomItems worked in the Java version. the player could then craft your custom bed at the workbench, place it in the world and use it (it would just behave like a vanilla object)


    Yes, this is about custom vertices & indices handling. This is a very useful thing, especially for natural-looking objects and optimisation (when you can merge meshed into one to reduce render calls)

    Does that mean you're mainly looking for an API to modify existing meshes (e.g. loaded through an obj file or a Unity asset), or an API to create entirely new meshes from scratch?

  • Does that mean you're mainly looking for an API to modify existing meshes (e.g. loaded through an obj file or a Unity asset), or an API to create entirely new meshes from scratch?

    It is more about new meshes, but replacing existing ones can also be useful. For example you can modify meshes of pre-defined objects or objects from another plugin, which probably can make some things easier. Actually, if it will be possible only create new procedural meshes - that will be already enough :)

  • Support for Unity Assets/Prefabs and FBX files would be really great :) :love:

    Then theoretically I can also work with C#

    Well, unfortunately it won't be possible to load custom C# scripts this way :/ We're using IL2CPP, so there is no Mono runtime which could load C# assemblies...

    Support for Unity prefabs / asset bundles would only cover models and materials / shaders (which need to be HDRP compatible)

  • Support for Unity prefabs / asset bundles would only cover models and materials / shaders

    This is a great thing, especially if it will be possible to use custom shaders on custom models :)

    Imagine, for example, bioluminescent cave flora that will change its light during time

Participate now!

Don’t have an account yet? Create a new account now and be part of our community!