Open Qendolin opened 5 months ago
Currently there is no support for rigid bodies with motion type LinearCast vs sensors (they will be treated as Discrete vs sensors):
I see. Maybe that would we worth noting in the documentation? Thank you for your quick response.
so the right approach would be to use ContactListener::OnContactValidate and do rejects there?
sensors seems to be misleading in a way (from intuition point of view) but the docs do mention what:
To create a sensor, either set BodyCreationSettings::mIsSensor to true when constructing a body or set it after construction through Body::SetIsSensor. A sensor can only use the discrete motion quality type at this moment.
overall looks like what for games you need a lightweight/fast event system in ContactListener so it does checks only for bodies with associated events/callbacks.
so the right approach would be to use ContactListener::OnContactValidate and do rejects there?
You could use OnContactValidate to implement a sensor, but getting this call doesn't mean that this is the closest collision. Hits are roughly sorted based on closeness, so for an object with motion type LinearCast it may be that you later receive another call to OnContactValidate with a closer collision which will result in the actual contact point.
ContactListener::OnContactAdded indicates that there is an actual contact and you can specify that that contact should be treated as a sensor by setting ContactSettings::mIsSensor. This disables the contact, but since we only store the closest contact point during the LinearCast sweep, this also means that the body could penetrate the object behind the sensor.
Hello, I've noticed an issue where rigid bodies using
JPH::EMotionQuality::LinearCast
do not report contacts with sensors when moving at high speed (~100 m/s).Here is my character body creation code:
My sensor is a static body, roughly 0.2m thick. The character body is moved using
body_->SetLinearVelocity
before the physics update.Using Jolt 4.0.2, and a 60Hz update interval with 1 collision step and the single threaded job system.