-
Notifications
You must be signed in to change notification settings - Fork 12
Creating prefabs to for machines
kremnev8 edited this page Aug 6, 2021
·
5 revisions
This is a detailed guide on how to create custom machines for DSP. This guide assumes you are familiar with unity, and have successfully followed unity dev environment setup guide.
- Acquire a 3d model that can be imported into unity. It can even be a default cube.
- Add your model to scene and right-click on it and select
unpack prefab
. Ensure that top object of your model is an empty game object. - Create a new prefab by dragging you empty gameobject into project folder. Open that prefab.
- Create BoxCollider on root object and set it to size.
Copy it
andpaste as new
. On that new collider setisTrigger
- Add scrips from DSP:
-
BuildConditionConfig
. Describes certain requirements about a machine, like where it can be built. To fill land points or water points I suggest using gameobjects to determine position values. -
SlotConfig
. Defines everything related to selection. Copy your collider size and center to its fields. It also allows to define where belts or inserters can connect. -
PowerDesc
. Defines how this machines relates to power system. You can set it to be a power node, generator or consumer.
- Add empty game object called
LOD
and addLODModelDesc
script to it. Here you need to define a few very important things.
- Mesh collider: This is how game checks if your cursor is on mesh or not. Make a simple mesh that resembles your object loosely.
- Mesh Data: This is where game is storing you ACTUAL model of the machine. Use AnimationBakerWindow from unity folder to create it.
- Verta path: .Verta files contain baked animation data. You need this file only if your machines has animations. Use AnimationBakerWindow from unity folder to create it.
- Lod Distance: How far from object do you need to be for it to become invisible (Vanilla buildings usually set it to values between 1000 and 5000)
Once you done this your prefab should look like this:
- Exit of out prefab window and select you prefab in scene
- Go to
Window->DSP Tools->Verta Animation Baker
You should see AnimationBaker window popup - If your mesh HAS animations select your animation clip, otherwise click
No animations
- Click Bake