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

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
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: