pmndrs / react-three-rapier

🤺 Rapier physics in React
https://react-three-rapier.pmnd.rs
MIT License
1.09k stars 62 forks source link

RigidBody not updating on drag #688

Closed AshhadDevLab closed 2 months ago

AshhadDevLab commented 5 months ago

Description:

I am using DragControls over a RigidBody. The issue I am facing performing this action is that the mesh is moving with the drag controls, whereas the rigid body or the physics component stays where it is and doesn't move.

Code

CodeSandbox

Tried Solutions:

I tried copying the world position of the original geometry and then update the position of the rigid body with respect to the world position.

niccolofanton commented 2 months ago

I was facing a similar problem, I think it's not possible to use a DragControl with a RigidBody directly inside.

When you drag, the control moves the mesh, and if you translate the RigidBody programmatically to the new position it will move again the mesh causing a chain reaction.

I solved using a RigidBody with a mesh inside and a DragControl with the same mesh but invisible.