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 How to Make a Video Game Player Input and Cameras Move the Player with Animation

Davidson Louis
Davidson Louis
873 Points

Can someone tell me what's wrong with this code, please? It says that Parameter 'Speed, 0f' does not exist.

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

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! There are a couple of things going on here. First, you should be using the SetFloat method, but instead, are trying to use the GetFloat method. The GetFloat method takes either a string or an integer and you are passing in a string but it isn't matching anything it can "get". You can find more information on the GetFloat method in the Unity documentation.

You should be using SetFloat method. This method can have several different parameters it can take, but we want the first one documented in the Unity documentation. This takes a string and a float. But as stated before your entire parameter is one string, instead of a string and a float because it's all inside of one set of quotation marks. Also, note that the method was not intended to be private. Take another look at the code Nick wrote:

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

Hope this helps! :sparkles: