input.getaxis not working

Hello - i’ve got a Problem:
i wrote some Code to get a Little ball rolling, but it really doesnt do anything - would be nice if someone could help.
heres the Code:
`
public class PlayerController : MonoBehaviour {

public float speed;

private Rigidbody rb;

void start()
{
    rb = GetComponent<Rigidbody>(); 
}

void FixedUpdate()
{
    float moveHorizontal = Input.GetAxis("Horizontal");
    float moveVertical = Input.GetAxis("Vertical");

    Vector3 movement = new Vector3(1.0f, 0.0f, moveVertical);

    rb.AddForce(movement * speed);
}

}
`

Hi @knorke3 ,

There are 2 problems in your script:

  1. The Start is written start (lowercase) so I guess you have plenty of Null Reference Error
  2. You forgot to use moveHorizontal

Here the working code (set the speed at 15f as default as it seems about right in the context):

public class PlayerController : MonoBehaviour {

    public float speed = 15f; // let's set a decent speed as default
    private Rigidbody rb;

    void Start() // Upper case because in C# casing counts!
    {
        rb = GetComponent<Rigidbody>();
    }

    void FixedUpdate()
    {
        float moveHorizontal = Input.GetAxis("Horizontal");
        float moveVertical = Input.GetAxis("Vertical");
        // Let's assign both x and z
        Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
        rb.AddForce(movement * speed);
    }
}

I hope this helps :wink:

I have the same problem, please help us.
I have also tested it with rb.transform.Translate (movement); and it does not work.

Thanks @DFT-Games,
Working fine for me now :wink: