0

I wanted to rotate a wheel collider object in unity.

I duplicated my back and front wheels objects to keep the position data.
It appeared perpendicular to the wheels. I cannot rotate it using the rotation tool or via the inspector.

Wheel collider perpendicular

As mentioned in this post: it could be solved using an empty game object for the rotation.

I tried to append it onto an Empty Game Object and rotate it. It did not work. Empty game Object

Thanks in advance

Felox
  • 503
  • 3
  • 10
  • 23

2 Answers2

3

I had the same problem. The solution is simpler than the other answer suggests:

WheelCollider objects are dependent on the orientation of a rigid body they are attached to. Assuming that your bike has a rigid body, the solution is to make sure that the X-axis orientation of the bike matches the X-axis orientation of the wheel colliders.

Based on this post:

https://forum.unity.com/threads/unity-5-wheelcollider-wrong-rotation.349596/#post-2264801

WheelColliders always point in the "forward" and "down" direction as the rigidbody they're attached to. The steerAngle value is relative to the rigidbody's forward direction.

Please bear in mind, however, that your bike's model(the visuals that display bike's frame) might have a different orientation from the object that contains the rigidbody that wheel colliders are attached to.

In my case Hierarchy looked like so:

  • MainScene
    • CarRoot
      • CarModel
      • WheelColliders
        • Wheel_FR
        • Wheel_FL
        • Wheel_RR
        • Wheel_RL

The CarRoot had a rigid body on it. When I rotated it, that would also rotate my model. Which was not good. So I had to:

  1. Unparent the CarModel and WheelColliders(made them children of MainScene)
  2. Rotate the CarRoot by 90 degrees on the Y-axis(to align its X-axis with that of the WheelColliders)
  3. Make CarModel and WheelColliders children of CarRoot again.

That did it for me.

MickeyDickey
  • 175
  • 1
  • 9
1

1-) Create a capsule game object, 2-) Make it like whell. 3-) Delete capsule collider and add mesh collider, then select convex., Now you have a collider like whell.

4-) Put your whell game object under this, and fix sizes. 5-) Delete mesh filter and mesh renderer in capsule object. 6-) Use transform.rotate(vector3.right) or left on created base object.

Akin Erkan
  • 273
  • 3
  • 14
  • I tried this but it did not work. In fact I still need a wheel collider to process a moving script. (Sterring and motor) – Felox Apr 12 '20 at 14:48