My endeavour seemed simple enough, load an X-Wing and, using the mouselook script, I could have it flying around in no time at all!
The mouse look worked fine, even though I hadn’t got the ship moving yet, I knew it would be a huge problem.
Faced with the brevity of my ineptitude, I googled myself silly to no avail.
I realise there are minds in this world to which the answer is crystalline, in all its splendour, but it escapes me.
I wanted to make the ship move forward, according to its rotation, when I pushed W. So in the area where the quaternion is calculated and added to the transform:
Quaternion xQuaternion = Quaternion.AngleAxis (rotationX, Vector3.up);
Quaternion yQuaternion = Quaternion.AngleAxis (rotationY, Vector3.forward);
transform.localRotation = originalRotation * xQuaternion * yQuaternion;
if(Input.GetButton ("Horizontal"))
{
rigidbody.AddRelativeForce(transform.forward * inputThrottle * MAX_FORCE_MAGNITUDE);
}
you can see I added some relative force. All this seems to do is make the model move in arbitrary directions.
I’m sure someone has encountered this, someone on these very forums, but believe me when I say I want to learn how to calculate the models velocity properly, and how to apply that to the model. I’m actually studying video games development at university!
If anyone could just make a quick post, or link me to one (I did search the forums, to no avail) to inform of the procedure holisticly, I would be eternally grateful to you.
Cheers.