Reply To: Chpt 2 – when I run the Hero doesn\\\'t move/turn
Home › Forums › Books › Mastering Unity 2D Game Development › Chpt 2 – when I run the Hero doesn\\\'t move/turn › Reply To: Chpt 2 – when I run the Hero doesn\\\'t move/turn
July 9, 2016 at 9:37 am
#10043
Keymaster
lol, you found one of my last remaining errata in the book which the proofreaders messed up on me and I missed it.
Basically the problem is in the Awake function, which the text tells you to discover the animator from the scene, however the line is missing :S.
However if you read further down in the “Extra Credit” section, the awake function is detailed in full. (basically they took the wrong line out of the previous example)
The full Awake function should look as follows:
1 2 3 4 5 6 7 |
void Awake() { // Setting up references. playerRigidBody2D = (Rigidbody2D)GetComponent(typeof(Rigidbody2D)); playerSprite = transform.Find("PlayerSprite").gameObject; anim = (Animator)playerSprite.GetComponent(typeof(Animator)); } |
Hope this helps.
-
This reply was modified 4 years, 7 months ago by
Simon (darkside) Jackson.
-
This reply was modified 4 years, 7 months ago by
Simon (darkside) Jackson.
-
This reply was modified 4 years, 7 months ago by
Simon (darkside) Jackson.
Simon (Darkside) Jackson
@SimonDarksideJ