Rotate a wheel with camber angle

392 Views Asked by At

I'm new to 3D design, so this might be a silly question.

I have trouble simulating wheel camber using rotation with Quaternion.

What I understand is that the rotation of the WheelCollider occurs along the X axis, whereas in my case the "visual wheel" is rotated 80 ° along the Z axis so the rotation occurs along the Y axis.

This code works well with the FL wheel because its axis is aligned with the collider axis, while it doesn't work with the FR wheel.

collider.GetWorldPose(out Vector3 position, out Quaternion rotation);
visual.transform.position = position;
// initialVisualRotation is the wuaternion rotation of the visual at Startup
// in this case: X=0 Y=0 Z=80
visual.transform.rotation = initialVisualRotation * rotation;

These are my local and global rotation axes for the right front wheel (FR).

Local axis Global axis

How can I "adjust" the wheel rotation without change initial axes (as I did for the FL wheel)? Are there some quaternion operations to adopt in these cases?

1

There are 1 best solutions below

1
On

A bit of workaround for not having to deal with messed up transforms is to make object a child of another empty object.This way you can make parent object rotated to make wheel tilted but Child( actual wheel) will have its original axis always not messed with and so you can use simple script to always rotate it around same axis that is always going to be the same despite whole system(hierarchy of objects) being " tilted". Parent is responsible on rotating around one axis and child around another. I think you need to take a step back and arrange your prefabs this way as it seesm you did not.