Hello! I’m using this script from documentation, to make a arcade car phisics.
var speed : float = 10.0;
var rotationSpeed : float = 100.0;
function Update () {
var translation : float = Input.GetAxis ("Vertical") * speed;
var rotation : float = Input.GetAxis ("Horizontal") * rotationSpeed;
translation *= Time.deltaTime;
rotation *= Time.deltaTime;
transform.Translate (0, 0, translation);
transform.Rotate (0, rotation, 0);
}
What i need:
- Get unfliping car, or make a fixed angle tilt of the car
- Off the controll car when it in the air, because it continues moving when i hold the button
- why it flies into the air when bumps into something on the speed? and twirl there like crazy too long?
Update
HI,
1 . To unflip your car use this simple code(Its the same)
var initialrot:Quaternion;
function Start(){
initialrot = transform.rotation;
}
function Update(){
//your code to check if its flipped or not
//if yes then
if(transform.rotation.z >=180 && transform.rotation.z <360){///////to check if your car is flipped or not
transform.rotation = initialrot;
}
}
2 . to check if you are grounded try using his script cause i am a little busy with my AI script so i am unable to post mine
Here is his script
(if you want a even simpler code so that you can understand please do notify me)
Edit
if you are using script from the link
funcyion Update(){
if(IsGrounded()){
///your movement code
//from var translation to transform.Rotate (0, rotation, 0);
}
}
3 . And for the rotation when you bump.Actually the rigidbody will take care of it by its self