Hello there,
I’ve been trying to make an open-world game where you are able to get behind the wheel of these ‘Fifth Element’-esque flying cars.
To give you an idea how the cars should look and react/manouver here’s a video from the movie “The Fifth Element”
I want these cars to fly smooth, feel heavy and it’s controls sophisiticated. Being able to make the car pitch up and down with the ‘UP’ and ‘DOWN’ arrow keys, make it roll sideways with ‘LEFT’ and ‘RIGHT’ arrowkeys. Accelerate with ‘W’ and brake with ‘S’.
Make the car turn (Giving it a fluid rolling effect too as it makes it’s turns) with ‘A’ and ‘D’.
This seems like one heck of a job to accomplish, and I just started out with Unity scripting. (Right now I’m working in Javascript, if there’s a better alternative I’d love to hear it.)
So far my controls are this little set of strings and code.
#pragma strict
var rotateSpeed = 20.0;
var speed = 10.0;
function Update() {
var transAmount = speed * Time.deltaTime;
var rotateAmount = rotateSpeed * Time.deltaTime;
if (Input.GetKey("down")) {
transform.Rotate(rotateAmount, 0, 0);
}
if (Input.GetKey("up")) {
transform.Rotate(-rotateAmount, 0, 0);
}
if (Input.GetKey("d")) {
transform.Rotate(0, -rotateAmount, 0);
}
if (Input.GetKey("a")) {
transform.Rotate(0, rotateAmount, 0);
}
if (Input.GetKey ("right")) {
transform.Rotate(0, 0, rotateAmount);
}
if (Input.GetKey ("left")) {
transform.Rotate(0, 0, -rotateAmount);
}
if (Input.GetKey ("s")) {
transform.Translate(0, 0, transAmount);
}
if (Input.GetKey ("w")) {
transform.Translate(0, 0,(transAmount * -2));
}
}
This is obviously very simple, and even though it does give a certain desired set of controls for my flying car, it’s very sharp. No smoothing whatsoever. For example; When you let go of the ‘gas’ you simply stop instantly.
But what I for example would like is for the car to have these ease in- and outs during movement.
I’ve been searching for a set of code to do the trick for a while now, but can’t really seem to get a hold on it.
So I’ll just ask it here myself; Any suggestions on what I might do? Change or create a completely different code?
Much appreciated!