Open jcowles opened 1 year ago
Actually, my issue was solved by including the physics type in the key:
<RigidBody
key={props.physicsType + props.index}
After thinking about this a bit more, I think this is a hack/workaround - this is just forcing react to create a new tracking object when the state changes, but really props.index
alone (which is a stable identifier) should be enough, no?
reopening
Indeed, this is intended to work! In fact there is a Demo of this working here:
https://react-three-rapier.pmnd.rs/dynamic-type-changes 🤔
However there is an odd situation that the RigidBody does not always go back from kinematicPosition
to dynamic
, unless the body is forced to collide with something. I believe that is a Rapier
bug - but it's an odd one!
@dimforge/rapier3d-compat@0.12.2
had an update related to this.
Fix bug that made dynamic rigid-bodies behave like kinematic bodies after being disabled and then re-enabled.
Is this still an issue in @react-three/rapier@0.14.0
?
This appears to still be happening. I can work around it with
rigidbody?.setEnabled(false);
rigidbody?.setEnabled(true);
whenever I'm changing the type. This is with @react-three/rapier
at 0.15.1
I have a rigid body:
If I change
props.physicsType
to "dynamic" (from "kinematicPosition"), the RB does not become dynamic, however if I initializeprops.physicsType
with the value "dynamic" it works.I've also tried calling
addForce
with wake=true, just in case the objects were sleeping and pushing the objects with another object, but nothing works.The React component is definitely re-rendering when the value changes and has the correct/expected props values.
Is this a bug?