- Home /
Make the rotation of a tire physically move a car
I want to create a "real" rubber tire that rotates and thereby moves the car physically. It's a slow car, no racing, and I want it totally realistic for certain functions in the game. It seems that making the wheel rotate is only visual. It does not move the car. The car is Rigidbody, and the wheel is attached, has wheelcollider. I'm using itween to smoothly rotate the tire with sineInAndOut. Rotation looks good, but car does not move.
Answer by Statement · Apr 17, 2011 at 03:43 PM
You need to make use of rigidbody.ApplyTorque and make sure that the physics material on the tires aren't slippery. Further, you need to bind the wheels to the chassis using joints. You probably need to make some sort of suspension joint to allow the car to travel on rough terrain, or it'll be too stiff and bounce around.
You could also apply the motion through the motor on the hinge joint I guess.
Works! Thanks!!! However, the wheel does not spin visually. The car moves, the wheel must obviously spin. But the wheel graphics don't spin.
Got it! This needs to be attached to the graphics, and linked to the WheelCollider: CorrespondingCollider : WheelCollider; function Update () { //transform.rotation = CorrespondingCollider.rotation Quaternion.Euler( RotationValue, CorrespondingCollider.steerAngle, 0 ); transform.Rotate(Vector3.right CorrespondingCollider.rpm ( 360/60 ) Time.deltaTime);}
Answer by Jason B · Apr 17, 2011 at 03:41 PM
You may want to check out this car tutorial provided by Unity.
Personally, I've mucked around with wheel colliders for days and still never got anything better than a slippery car that has trouble cornering and tips over no matter how heavy and low to the ground its mass is, so I'm inclined to believe that wheel colliders perform mediocre at best, but that would just be my own personal analysis.
You're right that rotating the wheel doesn't rotate the car. In actuality, you need to change the WheelCollider.steerAngle
in order to steer and WheelCollider.motorTorque
to spin the tires.
Answer by Jean-Fabre · Apr 17, 2011 at 04:01 PM
Hi,
You can also use a configurable joint and use that joint to turn the wheel. It works very well, but not as good as a wheel collider.
Bye,
Jean
Answer by Kurius · Sep 19, 2017 at 06:19 PM
Remove all colliders from your car, except for WheelCollider. Most common mistake is to put colliders on your tires, even though you are already using WheelColliders. In this case the colliders will conflict with each other, and even though your tires will be spinning, your car won't move.