Miscellaneous
Variable qualifiers
class test
{
[SerializeField] private float speed; // show a private variable in the Inspector
private const float maxspeed; // create const variable
private static float nbinstances; // class variable shared among instances, write test.nbinstances
[range(0f,100f)] [SerializeField] float test; // limit range values of the variable in the Inspector
}
Event Functions
FixedUpdate() { ... } // called at a regular pace, useful for applying forces independently of the framerate
Update(){...}
LateUpdate() { .. } // called after the completion of all the update() calls, useful when scripting a follow camera
Awake() { ... } // called immediately after instantiation, before any call of the start() function, useful to load resources
Start() { ... } // called just before the first render on screen
Objects Pooling
Instead of instantiating and destroying lots of objects, it is more effective to create a pool of objects, activate them when needed, and deactivate them instead of destroying them.
For this, we need to:
Create a bunch of objects at the beginning
Set up a list of objects in the spawn manager