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

Derian McCrea
Derian McCrea
1,370 Points

C# code throwing error for FrognLog tutorial.

Hey all,

I'm new and have never worked in C#. I'm as far as adding as a playerMovement script to my player(Frong). But when I press play it throws 2 errors saying:


!(in a yellow triangle) Parameter 'speed' does not exist. UnityEngine.Animator:SetFloat(String, Single) and !(in red stop sign) ArgumentException: Input Axis vertical is not set up.

To Change the input settings use: Edit -> Project Settings -> Input

My code is:

using System.Collections; using System.Collections.Generic; using UnityEngine;

public class PlayerMovement : 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 ("vertial");

    movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
}

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

    }
}

}


The Frog is a prefab that I downloaded and I'm editing it for this tutorial. The code written matches the tutorial video. I'm just not sure what and how i should fix this issue. Do I add another Component to the player which triggers Vertical axis?

3 Answers

The name of axis are case-sensitive. That means you must not forget the capital letter at the beginning.

Derian McCrea
Derian McCrea
1,370 Points

YES! Ok i'll keep an eye out for that! Thanks for the heads up Samuel!

No problem. And thank you for replying, very few people do so and it's a good feeling, even on small, easy answers like this one.

Derian McCrea
Derian McCrea
1,370 Points

Communication is key! I hope all my problems are small haha. I'll do my best to solve them before I post! :)