- Animator Component - assigns animations to GameObjects through an Animator Controller.
- Animator Controller - arrangement of animations and transitions (state machine).
- Animation - specific pieces of motion.
- Sprite Renderer - displays the 2D sprite on screen.
- import spritesheet and slice;
- add sprite renderer to Player;
- create idle animation clip;
- create Character Animation Controller;
- add idle animation to Animator Controller;
- add Animator to Player;
- assign Character Animator Controller to Player.
- Prefabs are game objects which we have turned into reusable templates.
- The original template is called the Prefab and the copies we add into our scene are called Instances.
- Turning a game object into a prefab means we can easily load into any scene in our game.
- If the player is pushing right, the velocity will be positive. If left, then negative.
- If movement right, we should face right. If left, face left.
- We can change the facing direction (right or left) by changing the localscale using +ve or -ve value.
- Only change facing direction if moving, so weird things don't happen when velocity is zero.
- Layers are useful if we have the same functionality across multiple GameObjects. E.g. ignored by camera, not clickable, collision check.
- To stop jumping anytime we use
Collider2D.IsTouchingLayers()
.
- Checks whether this collider is touching any colliders on the specified layerMask or not.
- Returns bool.
- Given a set of layer names as defined by either a Builtin or a User Layer in the Tags and Layers manager, returns the equivalent layer mask for all of them.
- Returns int (the layer mask created from the layerNames).
Mathf.Sign(float f);
- Returns the sign of f.
- Return value is 1 when f is positive or zero, -1 when f is negative.
Mathf.Abs(float f);
- Returns the absolute value of f.
- A tiny floating point value (Read Only).
- The smallest value that a float can have different from zero.
- With the following rules:
- anyValue + Epsilon = anyValue
- anyValue - Epsilon = anyValue
- 0 + Epsilon = Epsilon
- 0 - Epsilon = -Epsilon
- A value Between any number and Epsilon will result in an arbitrary number due to truncating errors.
- Coroutines are another way for us to create a delay in our game.
- The core concept to understand is that we start a process (ie. Start Coroutine) and then go off and do other things (ie. Yield) until our condition (eg. we've waited 2 seconds) is met.
We call:
StartCoroutine(NameOfMethod());
Our method:
IEnumerator NameOfMethod()
{
yield return new WaitForSecondsRealtime(time);
// Anything you want to do after waiting
}