Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Game Development

Unity sais that my code is wrong but I followed every step.

This is my code that doesn't work, please help :

using UnityEngine; using System.Collections;

public class PlayerMovement : MonoBehaviour {

private Animator playerAnimator;
private float moveHorizontal;
private float moveVertical;
private Vector3 movement;

// Use this for initialization
void Start () {

    playerAnimator = GetComponent<Animator> ();

}

// Update is called once per frame
void Update () {

    moveHorizontal = Input.GetAxisRaw ("Horizontal");
    moveVertical = Input.GetAxisRaw ("Vertical");

    movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);

}

void FixedUpdate () {
    if (movement != Vector3.zero) {
        playerAnimator.SetFloat ("Speed", 3f);
    } else {
        playerAnimator.SetFloat ("Speed", 0f)
    }
}

}

Marcus Gray
Marcus Gray
1,837 Points

Try and put a semi-colon on the end of your last line: playerAnimator.SetFloat ("Speed", 0f);

Thanks

1 Answer

Alan Mattanó
PLUS
Alan Mattanó
Courses Plus Student 12,188 Points

Hi Andrei, The error you get is:

"Assets/PlayerMovemen.cs(38,7): error CS1525: Unexpected symbol `}'"

The error can be one line before the error line 38. Look the end of the line 37 first. A semicolon " ; " was omitted at the end of the line. A tip to keep in mind: When you finish the line, always double check the end of line semicolon.

}}