input axis horizontal is not setup pls help

I keep getting the input axis horizontal is not setup can somebody please help me

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

public class Moveball : MonoBehaviour
{
    Rigidbody rb;
    // Start is called before the first frame update
    void Start()
    {
        rb = GetComponent<Rigidbody>();
    }

    // Update is called once per frame
    void Update()
    {
        float Hmove = Input.GetAxis("horizontal");
        float Vmove = Input.GetAxis("vertical");

        Vector3 ballmove = new Vector3(Hmove, 0.0f, Vmove);
        rb.AddForce (ballmove);
    }
}

Hey and welcome.
Generally speaking it is advisable to post the actual error message you are getting.
The problem you are having is because you misspelled the axis name tho. It’s case sensitive, so ‘horizontal’ does not exist (unless you define or rename it as such), but ‘Horizontal’ does. The same goes for ‘vertical’.

Hope this helps :slight_smile:

Edit: That said, you may wanna look into some C# naming conventions. As a rule of thumb you want to write variables in camelCase - starting with a lower case letter and capitalizing every following ‘word’. Class, method and property names are written using UpperCamelCase. Using the same conventions as others helps make your code more uniform and thus easier to understand for other programmers. It also helps to differentiate between variables and properties, or types and instances and so on.

1 Like

Horizontal and Vertical are case sensitive and they both begin with a capital letter. This is something you could have figured out by yourself, had you paid attention.

1 Like

In theory, all problems can be figured out by yourself if you just pay attention to details, read the documentation and occassionally read some scientific paper for algorithmic problems. However, forums exist to exchange knowledge, which also includes helping people who still struggle with the basics, and dont yet have an understanding of what an obvious solution is, or how to figure that out for themselves.
While there are a lot of repetitive questions where i’d like people to use the search function before opening a thread, this specifically is not something that just directly jumps at your face when you google it. That said, of course, if you googled properly you would find a solution.

No need to study algorithms to make sure you wrote your code correctly. The first things people must do before asking for help is make sure there are no typos in their code. Since I doubt the poster took his code out of nowhere, there’s a big chance that he just didn’t pay attention when he copied it.

1 Like

so it was my spelling or no?. because I’m still getting it. I changed horizontal to be ‘Horizontal’ and vertical to be ‘Vertical’ is there anything else I missed

Yes, you wrote ‘horizontal’ instead of ‘Horizontal’. Same for ‘vertical’. I thought i made that very clear tho.
Not to mention that another person answered the exact same thing.
And you could also just quickly test it in a fraction of the time anybody could answer in.

sorry that I edited it after you replyed but there is now more to add to it

So your line now looks like this and you are still getting the error?

float Hmove = Input.GetAxis("Horizontal");

You are only supposed to capitalize the ‘h’.

ok i fixed it now thanks for the help you where great at explaing it to me