Option 2 is more challenging, and I’m going to leave it at that as homework! Possible solutions could include: Private static IEnumerator SetupNewGameObject ( Vector3 spawnPosition, Quaternion spawnRotation, TechType objectTechType ) This simple static method is all you need: TechType is simply a C# enumerator that contains references to a load of prefabs that you can spawn.
The code to create a new instance from a prefab is really straight forward and only requires that you know the TechType of the object you want to create.
This isn’t as complex as it might seem at first, and actually, calling asycnhronous co-routines will very quickly become a well used tool in your modders toolbox, once you get the hang of it and come to recognise the benefits of freeing up valuable update cycles while Unity does it’s thing.Įither way, follow these steps and you’ll be able to spawn and use your own object instances within you mod, and here’s how it’s done. The critical difference is that the original game has a synchronous method and Below Zero has an asynchronous mechanism. However, the process of using these to create instances is different in Subnautica and in Below Zero. You can get hold and reuse a number of pre-created prefabs included in both of the Subnautica games. So, you can increase the aggressiveness of your new Snowstalker, or even add new behaviours and components to change the way it behaves. Once you’ve used a prefab to create a new instance, you’re free to mess around without impacting other instances. This makes life really easy for a developer or modder who wants to create new object instances and tweak them. If we subsequently amend the prefab, all 20 instances inherit this change. To create a gang of murderous beasts, you need simply use the prefab to generate 20 new SnowStalker instances from that prefab, and place them around the map using their Transform. So, we may have a Snowstalker prefab, that contains all of the components and definitions that make a working, moving, murderising Snowstalker. Think of a prefab as a template or blueprint, if you like, that describes an object in your game that be used to create many instances of that object, without having to reconfigure each and every instance. Unity, and therefore the Subnautica games, have a concept of prefabs, knowledge of which can really help you in your modding life.