Roll a ball tutorial problem, axis are inverted?

Hi everyone,

I am new to unity, so I figured I’ll start with the beginner’s tutorials. I am currently trying the Roll a ball tutorial. I am working on mac os with Visual Studio. When I paste the script from the unity tutorial page to make the ball move, it wasn’t working at all. Unity just kept telling me to look for compile error. Then I took a closer look at the video tutorial and notice that the code from the unity page was missing after the rb = GetComponent(); so I’ve putted the missing word and end up with the following script (wich is still not working)

using UnityEngine;
using System.Collections;

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(moveHorizontal, 0.0f, moveVertical);

    rb.AddForce(movement * speed);
}

}

Now Unity won’t say to me that there are any errors, I can have acces to the game view and the ball is moving. However, if I use the arrow keys the directions are inverted, the Horitontal axis is inverted with the Vertical axis. So I figure if I invert the horizontal axis with the vertical axis in the script, that it might solve my problem. So now I am dealing with the following code (still not working):

using UnityEngine;
using System.Collections;

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(moveVertical, 0.0f, moveHorizontal);

    rb.AddForce(movement * speed);
}

}

Indeed, now the vertical axis/arrow keys are working properly, however, the horizontal ones are still inverted. For example, if I press left arrow key, the ball will go to rigth and vice-versa.
Does anybody has an idea what mihgt be wrong about this scripts or my interface?
If so could please explain the problem to me and indicate me a solution?

Thanks in advance for your help and advises!

Cheers

Guillaume

One thing to check is the way objects are aligned in your world. It is conventional in mathematics to use a right-handed coordinate system where z = up. But many applications use different conventions. Unity uses a left-handed coordinate system in which y is up. See if this points in the direction of an answer for you. (Add more detail to your question based on exploring this if you think it might help.) Good luck. :slight_smile: