Tutorial - Creating custom blocks

maritaria

Well-Known Member
Joined
Apr 14, 2016
Messages
126
Likes
165
Points
450
Age
109
Website
nuterra.tech
#1
The following tutorial is copied from this github example project.
The github page contains gifs for each step, they could not be added since forum posts are limited to a maximum of 3 images (for some reason)

Getting Unity
First, you need the correct version of the Unity Editor. This is version 5.4.0f3, creating blocks may work with other versions, but this is untested. We use this version because that is the version TerraTech is build with. Unity download page

Setting up the project
  1. Download or clone the repository onto your computer.
  2. Open the project with Unity 5.4.0f3.
  3. Click Nuterra > Build AssetBundles to verify the assetbundles can be succesfully build.
Creating your own block
Album of gifs for each step

Setting up the scene
  1. Add a cube to the scene (3D Object > Cube).
  2. Set the position of the cube to (0, -1, 0)
  3. Add an empty GameObject to the scene (this will be referred to as your root object).
  4. Set the position of the root object to (0, 0, 0)
Adding your model
In order to add a model to your block, the model should already be imported into the Unity Editor.
  1. Drag the model onto the root object, so it will be put inside of it.
  2. Change the scale, position and rotation of the model to be correct for the block
  3. Add colliders (note: if you want to use mesh colliders, they must be convex!)
Setting the information of your block
  1. Add the following script to the root object: Scripts > Nuterra.Editor > Custom Block Prefab
  2. Setup the information to your liking.
  3. Make sure the BlockID is unique, otherwise Nuterra will throw an error during startup.
  4. Make sure the dimensions of your block are at least 1 in each direction.
Setting up your blockpack as assetbundle
  1. Create a folder for your blockpack, it must exist under /Blocks, example: /Blocks/MyFirstPack
  2. Set the asset bundle of your blockpack folder with a name, it is handy to put all your assets in this folder so they all get serialized
  3. Drag the root object into your blockpack folder to save the prefab To save future edits on your custom block, you need to use the Apply button on the root object.
Installing your blockpack
BlockPacks are put in the /GeneratedAssetBundles folder of the Unity project. To install these, put them in TerraTech/Nuterra_Data/BlockPacks/

You can use the following script to make copying the required files easier:

/GeneratedAssetBundles/copy-to-nuterra.bat

@Echo off
set TT_ROOT=D:\Program Files (x86)\Steam\steamapps\common\TerraTech Beta
set PACK_NAME=myfirstpack

set TT_BLOCKS=%TT_ROOT%\Nuterra_Data\BlockPacks
if not exist "%TT_BLOCKS%" mkdir "%TT_BLOCKS%"
copy /Y %PACK_NAME% "%TT_BLOCKS%\%PACK_NAME%"
copy /Y %PACK_NAME%.manifest "%TT_BLOCKS%\%PACK_NAME%.manifest"
pause
 

Nightblade Greyswandir

Nothing is good enough!
Joined
Feb 3, 2017
Messages
2,709
Likes
2,976
Points
575
Age
44
Location
Terraland
Website
ngttadventures.blogspot.se
#5
If you make a new crop then you'd be a modding hero... that's why I'm skeptical as to if you can do it o_O.

Don't get me wrong, I think it's possible if you try but do you really plan on adding a whole new (fully functional) corp?
Only real obstacle is that I have to learn how to make unity animations and how to make block "do" things in TT way. I know 3D modeling, I know how to work with textures and materials. I know how to do animations but not in unity so that will be little new, but main thing is to make "function" blocks, that have behaviors and actions, as that is something I never did.
Worst case is that I will just make set of building blocks in different shapes and few animated blocks, best is that I will succeed to make functional corporation.
 

Exund

Fancy Modder
Joined
Sep 1, 2015
Messages
699
Likes
922
Points
505
Age
19
Location
Somewhere in space, near my Techs (Switzerland)
#6
Only real obstacle is that I have to learn how to make unity animations and how to make block "do" things in TT way.
@maritaria and @WhitePaw2002 already managed to do animations for blocks so i'm pretty sure that they will accept to teach you how.

And yeah for wheels and weapons it seems very difficult to implement cause of a big number of classes that are used
 

Nightblade Greyswandir

Nothing is good enough!
Joined
Feb 3, 2017
Messages
2,709
Likes
2,976
Points
575
Age
44
Location
Terraland
Website
ngttadventures.blogspot.se
#8
This is around 90 minutes of work.
tt.jpg
So 3D is really not a problem. I will need week or two to populate 3D with all basic and few special blocks. As I was thinking to go with relatively clean white (space program) look, with just a few details, it will not be more than a week to set texture and to try how it look like. This is just for rough start. Then polishing of 3D and optimization for fast rendering... then polishing of textures and fine tuning of look and feel... So first basic blocks maybe will be available in minimum four-five weeks. (If you want to play with no-texture blocks that can be relatively soon)
 

maritaria

Well-Known Member
Joined
Apr 14, 2016
Messages
126
Likes
165
Points
450
Age
109
Website
nuterra.tech
#12
Is there currently a way to call upon existing code? Either with just Unity, or your editor?
You cant quite write code for custom blocks directly, instead you have to add components to your game objects that contain the code. For example, lets say you have a "jump" component, which has code so that when space is pressed the gameobject jumps in the air. The only thing you can do with custom blocks at the moment is make static ones or have a looping animation. For now its only for aesthetics.
 

Nightblade Greyswandir

Nothing is good enough!
Joined
Feb 3, 2017
Messages
2,709
Likes
2,976
Points
575
Age
44
Location
Terraland
Website
ngttadventures.blogspot.se
#13
You cant quite write code for custom blocks directly, instead you have to add components to your game objects that contain the code. For example, lets say you have a "jump" component, which has code so that when space is pressed the gameobject jumps in the air. The only thing you can do with custom blocks at the moment is make static ones or have a looping animation. For now its only for aesthetics.
So limits are no production blocks, no weapons and no wheels? Can we apply existing behaviors from game to modded blocks?
 

Exund

Fancy Modder
Joined
Sep 1, 2015
Messages
699
Likes
922
Points
505
Age
19
Location
Somewhere in space, near my Techs (Switzerland)
#14
So limits are no production blocks, no weapons and no wheels? Can we apply existing behaviors from game to modded blocks?
Yes othervise our blocks wouldn't be damagable but the compoments for Wheels and Weapons contains multiple gameobject with specific names and specific variables which are kinda hard to explain how they're set/named
 

maritaria

Well-Known Member
Joined
Apr 14, 2016
Messages
126
Likes
165
Points
450
Age
109
Website
nuterra.tech
#15
Yes othervise our blocks wouldn't be damagable but the compoments for Wheels and Weapons contains multiple gameobject with specific names and specific variables which are kinda hard to explain how they're set/named
Actually no, those are patched on by the block pack mod.