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 trialHenrik Nord Aa Kristiansen
815 Pointsim 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!
Henrik Nord Aa Kristiansen
815 PointsParameter 'speed' does not exist. UnityEngine.Animator:SetFloat(String, Single) Movingfrog:FixedUpdate() (at Assets/Scripts/Movingfrog.cs:30)
Timothy Schmidt
4,806 PointsThat 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
815 Pointsthis 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
4,806 PointsJudging 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.
Henrik Nord Aa Kristiansen
815 Pointsthank you
Timothy Schmidt
4,806 PointsTimothy Schmidt
4,806 PointsCould you provide the error text?