- Home /
How to keep wheels in place?
So I have a bike texture with a polygon collider attached to it, then I have to wheels that are rotated when I press W or S, and at the same time the bike goes back and forth respectively to the key pressed down. But there is one thing that is not working properly, when I try to go up on slopes the wheels tend to be off quite a bit from the original position they had, and I've tried fixing the position with sliders, scripts, you name it. And they also have rigid bodies because if I don't have rigid bodies on them their circle colliders radius grow for some reason and that's also problematic, but solved with a rigid body. But my question is how do I keep the wheels in place no matter how much they are tilted/angled? Keep in mind that this is a 2D game and that the wheels are separated from the bike body, meaning that the bike itself has no wheels from the beginning and that's when the external textures I made come in and act as wheels and rotate when told to do so.
Have you looked at wheel colliders?
http://docs.unity3d.com/$$anonymous$$anual/class-WheelCollider.html
Answer by ZANTcr · Aug 05, 2014 at 01:07 AM
Hi I did a 2D Vehicle Control for the asset store, in my script the WheelJoint2D are created automatic, but some tips for your vehicle are:
Make your wheels child of the carbody. The carbody and the wheels need a rigidbody2d. In your carbody add 2 WheelJoint2D. In the WheelJoint2D drag and drop you wheel to connected rigidbody option. Adjust the anchor option of the WheelJoint2D. Your wheel object dont need WheelJoint2D, just your carbody.
Your answer
Follow this Question
Related Questions
Bike tut for bike nut ? 0 Answers
gameObject with 2 colliders with different layerMasks ? 1 Answer
How is wheelCollider RPM calculated exactly? 1 Answer
F-Zero Game - Collisions/Physics. 1 Answer
methods of keeping bikes upright ? 1 Answer