how rotate wheels with wellcollider?

1303144--60701--$360软件小助手截图20130719223119.jpg
hello, I’m totally a beginer of scripting…
I set my first car game like this, with wheel colliders add to each wheel mesh.But how steer or rotate wheels? a motoTorque give to wheel colliders only lead the car slide …:rage:
should i use transform.Rotate ?

You don’t rotate the wheel collider…they are just a special type of collider that applies a force to your rigid body based on the motor torque and brake torque settings that you specify. The wheel graphics are usually totally separate game objects and those are the things you rotate. You can use the rpm property of the wheel collider however to determine how fast you should be rotating your actual wheel mesh game objects. Wheel colliders should not be rotated…in fact your sound like they are working just fine. You just need the graphical versions of your wheels to be rotated now to provide the illusion.

thanks, but I still confused, should I finally use transform.Rotate to rotate actual wheel meshes?

Yep :slight_smile:

You can figure out how much you should rotate your wheel game object using the rpm property of the corresponding wheel collider you are using to represent it in the physics system, You just need to convert wheel revolutions per minute into degrees per second and then scale by deltaTime to get the rotation amount for the current update. Something like this :-

myWheelGraphicTranform.Rotate(Vector3.right * wheelCollider.rpm * 2 * Mathf.PI / 60.0f * Time.deltaTime * Mathf.Rad2Deg );

myWheelGraphicTransform is the transform of the wheel mesh and wheelCollider is the Wheel Collider

thank you very much,I think I got the answer :razz:

Hi SharpC and welcome to Unity.
What you are trying to do is fairly advanced for a new scripter.
I’d suggest starting doing a few weeks worth of video tutorials… there are tons. Once you’re comfortable with scripting then move onto looking at creating a car system.