wheelcollider.getworldpose vs manually assign rot and pos

Hi all,
So I’ve been looking at tutorials and the built-in vehicle standard asset and see that there are 2 ways of rotating and positioning the wheel mesh.
One is using wheelcollider.getworldpose, basically setting the rotation and position of the mesh to those of the wheelCollider.
Second is setting the rotation and position of the mesh manually, say:
wheelTransform.position = wheelColider.position
for rotation it’s more complicated, but in general calculate the rotation speed of the wheelCollider and rotate the mesh transform accordingly, and get the z rotation ie steering angle of wheelcollider and set the mesh transform accordingly.

Is there any difference between these two implementations in terms of optimization or accuracy?

The main difference is visual. GetWorldPose gets updated on each FixedUpdate and the interpolation settings have no effect. This means, for example, that if you play a scene in slow motion (Time.timeScale < 1) the movement of the wheels won’t look smooth.

On the other hand, adjusting the rotation and position of the meshes manually may be done at Update, providing visually smooth movement in all condition.

However, note that setting the pose manually is not straightforward. wheelTransform.position must be wheelCollider.position + suspension position. The position of the suspension is not exposed, so you have to either compute it via GetGroundHit > WheelHit.point, or throwing a Raycast for getting the contact point. Then you need to subtract the radius in the Y axis. Things get more complicated if you want to have the WheelCollider’s Center property in consideration. Depending on the method you use, the solution will be more or less efficient.

Well that’s … a lot of extra steps.
So basically if I have some sort of slow-mo feature then I have to update the visual manually, otherwise using getWorldPose would be enough?
From what I’ve seen updating manually requires quite a lot of extra physic steps, would that affect performance?

Personally what method would you use if you’re not going to modify timeScale?

Yes, that a good criteria.

Manually updating the visual wheel may also be required if:

  • You want the WheelCollider not to be located at the center of the wheel. As far as I know, GetWorldPose assumes the WheelCollider is located at the center of the wheel.
  • You want correct visual accuracy. As the wheel pose is updated in FixedUpdate, the visual wheel won’t be rotating at the same rate the screen is getting refreshed. Not a big deal, but easily noticeable (at least for the trained eye) when everything moves at 75-100 Hz but the wheel rotates at 50Hz.

More calculations are required, but I haven’t seen these to be an issue for calculating the suspension via GetGroundHit > WheelHit.point. Throwing an additional Raycast per wheel per visual frame is something to consider in terms of performance.

I don’t use GetWorldPose due to it’s limitations. The wheel moves and rotates at much smoother rate when modified manually. I compute the suspension state from GetGroundHit > WheelHit.point as “Fast” method. I throw an extra Raycast as “Accurate” method. My vehicle physics packages expose a setting to choose between these both methods.