[Bug] Physics - Model gets out of sync from physics collision shapes

Hey again,

This time I’m here to report a but that’s bit odd and that scared me for a while until I enabled Physics Shape Debug (using the built-in script).

Basically, it seems that, when moving, the meshes (models) drift away from the collision shapes in the direction you’re going in.

Here is a screenshot showcasing it on my suspension:

You can very clearly see the disparity between the wheel and the suspension arms models and physics shape (the physics shape seem to be right according to the way it simulates and moves.)

Here is a screenshot of how it is when “resting” (it’s wobbly af hell, but well… Fixing that comes later.):

from the side:

At rest:

I have to admit that I am 100% clueless as for the reason this happens, but it’s quite an annoying one (since even if the simulation gets correct and fixed, visually it will look wrong. :frowning: )

Hope this can help improving Xenko :slight_smile:
If you’ve got an idea as to what may be the culprit, I’ll gladly look into it as well. (but well, digging into such a complex piece of software would be no easy task for me. x) )

Cheers,

Thanks for the report but I don’t understand exactly.
It’s just the debug shapes ? Or even the simulation and the simulated entities are going out of sync?

It’s pretty much the opposite.

The Collider shapes are at the proper position, however, the models are being shifted forward in the direction of the velocity. It’s only the visual model, so the collisions etc still happen based on the correct location of the collider shapes.

I’m not sure if it’s the complete entity or just the model though, I will need to check on Monday (unless I did a commit before leaving the office :slight_smile: )

I’ll try to print the difference between the entity and the physics shape world location, to see if they match. Or stuffs like that. (I may have to jump back on another project though, sadly :frowning: )

This is a good example, we can see that the physics shape of the rear wheel is close to be colliding with the bumper, but we can also see that the model of the mesh is already through the geometry.

My tests so far has led me to notice that systematically, the direction of the object’s shift is the same as the current velocity of the object. For instance, my car is going forward, thus the wheels are being offset forward. When it drifts, the offset goes on the exterior side of the curve of the drift (turning and drifting to the left would see the wheel models getting offset on the right.

Ok. I figured it out… Because my wheels were child of a dummy object which were childs of the body of the car… It was applying a double velocity it seems… :frowning:

Lesson of the day: Don’t parent your objects… Because that breaks it. But to be honest, that’s a pain as it makes building the original object relatively to each others much harder…

Can you show us a screenshot of your object hierarchy? I’m curious to see what was your setup exactly.

Sure,

This was my hierarchy:

This is the fixed Hierarchy:

Please note that the " Box3x1x1" element is in fact the body of the car. I just didn’t rename if after changing it from the cube.

There’s also an issue with Nesting Prefabs and having multiple instances of a prefab in a prefab, if the child being duplicated had scripts referencing some of its entities. (because when you put multiple prefabs instances, their components all share the same name and it seems like those script references are not GUID-based but name-based, but that may be for a separate topic. :slight_smile:

1 Like

Since your question was answered, I like to ask you a question instead of creating a new thread.
Does Xenko Physics use PhysX.WheelColliders? I can’t find anything about it in the Docs. Or are you applying your forces directly to the rigid body?

As far as I know, no it does not. Although I know that they would like to integrate the vehicle classes from Bullet into Xenko when they can, as of now. they’re not in.

In the current example, forces are being applied directly to the rigid bodies yes. :slight_smile:

EDIT: Oh right. I misred and didn’t see you mentionned PhysX. As Kryptos says below, Xenko uses Bullet Physics and thus PhysX comparison are not relevant, however, Bullet Physics also has some vehicle classes, although not implemented currently in Xenko. (If I’m correct)

Xenko uses bullet physics. So comparing it to PhysX is not really relevant.