-
From what I understand about OnContactPersisted, I would expect to receive a call to it on every update of the physics system. But it seems like I only receive OnContactAdded on the first time the player makes contact, and then OnContactPersisted is never fired. The player is a dynamic sphere in this case, and the mud plane is a kinematic triangle mesh sensor. Am I misunderstanding how this works? I also created another kinematic triangle mesh object for testing, and when the mesh is solid, the persisted event constantly fires, as expected. But when set as a sensor, it is unreliable, even when the dynamic sphere is obviously intersecting the triangle mesh. Using v4.0.2. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 10 replies
-
Sorry for offtopic, the game looks nice, wanted to ask did you use 1 shape for your terrain/level or something else? |
Beta Was this translation helpful? Give feedback.
-
As long as the object doesn't go to sleep, you should receive an OnContactPersisted every frame for a dynamic (!) rigid body vs another rigid body. In this case you're using a mesh shape which has no concept of inside and outside, so unless your sphere is intersecting with a triangle of the mesh (which I cannot see from your screenshot) you will not receive any callbacks (but I'd expect you to at least receive an OnContactRemoved). |
Beta Was this translation helpful? Give feedback.
-
Just tested this by lowering the plane a little bit -- this is exactly what's going on! Is there any remedy for this? |
Beta Was this translation helpful? Give feedback.
In this case you can choose, see: ShapeCastSettings::mBackFaceModeTriangles.
Now that I think of it: You don't need to use sensors in this case, you can also every frame do a CollideShape check with CollideShapeSettings::mBackFaceMode = CollideWithBackFaces of the sphere vs the world (and the preferably with a layer that only collides with these mud plane meshes) to detect overlaps. This would probably result in a similar performance compared to using the sensor.