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

C#

Henrik Nord Aa Kristiansen
Henrik Nord Aa Kristiansen
815 Points

im writing the code in microsoft visual st.. and it workes fine exept it dose not seam to understand this ("speed", 3f);

okay so i have bin looking everything over a million times and it just seems that "f" is the wrong thing to write after the speed number if (movement != Vector3.zero) { playerAnimator.SetFloat ("speed", 3f); } else { playerAnimator.SetFloat ("speed", 0f); } if you can see my mistake in this plzz tell me!

Timothy Schmidt
Timothy Schmidt
4,806 Points

Could you provide the error text?

Henrik Nord Aa Kristiansen
Henrik Nord Aa Kristiansen
815 Points

Parameter 'speed' does not exist. UnityEngine.Animator:SetFloat(String, Single) Movingfrog:FixedUpdate() (at Assets/Scripts/Movingfrog.cs:30)

Timothy Schmidt
Timothy Schmidt
4,806 Points

That sounds like your playerAnimator doesn't have a speed variable. Make sure you didn't capitalize the variable name differently in the animator, i.e. Speed, SPEED

Henrik Nord Aa Kristiansen
Henrik Nord Aa Kristiansen
815 Points

this is all of the code... i cant find the mistake: public class Movingfrog : 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);
}

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

}

Timothy Schmidt
Timothy Schmidt
4,806 Points

Judging by the error message, the script isn't the problem. The problem will be inside the Animator component. You have to look at the Animator and make sure your variable is correctly named.