Things I wish I knew when I started Unity

1. How to use Coroutines

This is very, VERY helpful in Unity.  This is something you can’t do with Unreal in C++.

But anyway…a coroutine is a function that can be interrupted mid-way through.  Here is a basic one:

IEnumerator TestFunction()
  yield return new WaitForSeconds(5f);

Then to run the coroutine, just type


…into one of the regular functions.


2. Timescale

Timescale has many uses.  I typically use it to pause the game.  It modifies everything, except things tagged to ignore time scale, such as a UI animator component.

Time.timeScale = 1f;  //Play game at normal speed
Time.timeScale = 0.5f;  //Play game at half speed
Time.timeScale = 2f;  //Play game at double speed.
Time.timeScale = 0f;  //Freeze game completely


3. If it moves and has a shape, give it a rigid body

If it has a collider and no rigid body, you’d better not move it- or the entire scene will get recalculated.

If it moves via transform.position, just give it a rigid body and set it to kinematic.  Kinematic rigid bodies can’t be effected by other rigidbodies that touch it.

4. Unity animation can apply to all serialized variables

What do I mean by that?  In addition to being able to animate common things such as position, rotation, and color, you can also animate custom component variables.   Basically anything that is visible in the inspector, you can animate.

P.S.: Animation can be unaffected by Timescale

5. AudioClips can be played without an AudioSource

…sort of.  There is a static function that creates an AudioSource that is deleted after the sound is done:

AudioSource.PlayClipAtPoint(clipRef, position, volume);



That’s all for now.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s