- Home /
Turning Rigid body currently in contact with ground.
Hi all.
Am making a racing car game. Micro Machines style!
I've got the car moving forward and backwards using the rigid body commands in the fixed update function (JS). However I can't seem to get the vehicle to rotate. I'm sure its quite simple, any ideas?
here is current controller code:
#pragma strict
var handling : float = 100.0;
var speed : int = 100;
function Update () {
}
function FixedUpdate () {
var rightTurn : Quaternion = Quaternion.Euler(0,handling,0);
var leftTurn : Quaternion = Quaternion.Euler(handling-(handling*2),0,0);
if(Input.GetKey("right")){
rigidbody.MoveRotation(rigidbody.rotation * rightTurn);
};
if(Input.GetKey("left")){
rigidbody.MoveRotation(rigidbody.rotation * leftTurn);
};
if(Input.GetKey("up")){
rigidbody.AddRelativeForce(speed,0,0);
};
if(Input.GetKey("down")){
rigidbody.AddRelativeForce(speed-(speed*2),0,0);
};
}
The problem is it moves really slowly, almost like the friction is stopping it. Any ideas?
Answer by TheDarkVoid · Nov 22, 2012 at 11:17 PM
you can use Rigidbody.AddTorque() xor Rigidbody.angularVelocity or even both. in some cases you could even just use Transform.rotate().
Your answer
Follow this Question
Related Questions
Physics driven cars without Wheel Colliders. Is it practicable? 1 Answer
car wheels brakes 2d 1 Answer
Unity Car Tutorial 1 Answer
How do I "remove/disable" collision? 3 Answers
How to set max speed for this car ? 1 Answer