Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Game Development How to Make a Video Game Player Input and Cameras Move the Player with Animation

Angus Eliott
Angus Eliott
3,793 Points

float: Get or Set?

I was told to type out the following code:

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


Microsoft Visual Studio said that playerAnimator.SetFloat did not exist. and when I rendered the game in Unity, it told me that it could not be rendered because of a scripting error. Microsoft Visual Studio suggested I use playerAnimator.GetFloat instead. but when I rendered it in Unity again, the frog just didn't move.

2 Answers

J.D. Sandifer
J.D. Sandifer
18,813 Points

Ted's on the right track here - there are a couple subtle errors. I believe you want those lines do read more like this:

playerAnimator.SetFloat("Speed", 3f);

Notice the capital 'S' in speed and the second quotation mark goes before the comma. You want two arguments - a String ("Speed") and a Float (3f) - not one String ("Speed, 3f").

Just make the same type of correction to both those lines and you should be good.

I'm not actually taking this course, but when I looked at the video the first argument in both SetFloat methods is "Speed" with a capital S, rather than the lower case s you have in your script. Perhaps that is causing the problem.