Hello,
Here is the script I did after some testing, but I don't get why it works.
function FixedUpdate() {
transform.Rotate(Vector3.up * Input.GetAxis("Horizontal"));
if(Input.GetAxis("Vertical") > 0)
{
transform.Translate(Vector3.forward * ( Input.GetAxis("Vertical")));
//rigidbody.AddRelativeForce(Vector3.forward * (1000000 * Input.GetAxis("Vertical")));
}
}
I have a game object which implement a rigid body component and the script above, and which contains my ship's object (mesh + collider etc).
The script works the same way with the commented part instead of the line right above.
My question is : why my translation works correctly since I never transform the direction it follows according to my rotation?
I mean, I usually did(or saw) things like
myDirection = transform.TransformDirection(myDirection);
to take care of the rotation, but this script works perfectly without that.
Can someone explain me why?
Thanks.
ps : I'm new to unity, so please don't be rude ;)