Make a Thing for the world of ThingThingThing

You will be editing your Thing class down below in the editor.
Dont be scaried by the look, it is very strighforward.

When you are finished, just click the submit button.

using UnityEngine; namespace ThingSpace { public class ClassNamePlaceholder : Thing { public override void Init() { //movement related speed = 5; seperation = 0.1; cohesion = 1; //shape and size meshIndex = 3; //which geometry you want to use, range 0 - 43 width = 1; height = 1; depth = 1; spikyness = 1; //color red = 0.3; green = Random(0, 2); blue = 0.2; } public override void IntervalAction(Thing other) { //call a function like this Clone(other); //we can also use if statement to add a condition before an action //in this case we throw out a random number between 0 and 10, if it is bigger than 3, this Thing will Seek if (Random(0, 10) > 3) { Seek(other); } } public override void OnTouch(Thing other) { //another if statment, now it will see if the other Thing has more than 100 vertex, if yes, then Steal, else, Gift if (other.vertexCount > 100) { Steal(other); } else { Gift(other); } } } }

Syntax

A few basic syntax stuff to keep in mind while coding:

  • Everything is case-sensitive.
  • Semicolon ; means the end of line. you need it at the end of every line.
  • Curly Bracket { or } Do not add or delete any of it. Anything between a opening curly bracket and a close curly backet is a code block.
  • Comment //: any text starts with a // means all text after // is a comment, meaning those text would be ignore by the machine and only visible to humans. There are some sample code with // in front of them, you can delete the // so you dont have to type the code by youself.

Variables

variables can be assigned directly using =
for example:
speed = 1.1

available variables:

decimals(float):
please respect the range, or it might break the simulation. Remember, case-sensitive.

  • meshIndex // an integer, which 3D model to use. range: 0 - 43
  • click here for the look at table
  • speed // how fast it can move: range 0-20
  • cohesion // how likely it will move towards other things 0 - 10
  • seperation // how likely it will move away from other things 0 - 10
  • vertexCount// how many vertices this Thing has at this moment: range 3-100
  • width // range 1-5
  • height // range 1-5
  • depth // range 1-5
  • red // range 0-1
  • green // range 0-1
  • blue // range 0-1
  • spikyness // range 0-1

all variable assignment needs to go into the Init() function code block.

Functions and Events

Functions

Functions are actions your Thing can perform. It usually is something your Thing does to another Thing. Every function needs a parameter. Parameter is the word inside parathesis. In our case, the prameters is probably called other

a function is called like this: Clone(other); DO NOT forget to add the ; at the end of each function call.

available functions:

  • Clone(other) : create a copy of the other Thing you meet
  • Erase(other): delete the other Thing you meet
  • Steal(other): steal vertices of the other Thing you meet
  • Gift(other): give vertices of your to the other Thing you meet
  • Seek(other): start chasing the other Thing you meet (stop chasing automatically in 5 seconds)

Events

All functions need to be placed inside a code block ( aka between { and } )
In our case, all functions need to be placed inside two event blocks:

the IntervalAction : functions placed here will be executated every 5 seconds;

public override void IntervalAction(Thing other)
            {
                   //call your functions here.
                   //example:
                   //Clone(other);
            }
            

and the OnTouch event: functions placed here will be executed when your Thing bump into other Things:

public override void OnTouch(Thing other)
            {
                   //call your functions here.
                   //example:
                   //Erase(other);
            }