How to get velocity of a mesh with React-Three-Cannon?

57 views Asked by At

I have a mesh declared by using @React-Three/Cannon:

const [obstacleRef, obstacleApi] = useBox(() => ({
  mass: 1,
  position: [0, 2, -5],
}));

I change the velocity in useFrame:

useFrame(() => {
  obstacleApi.velocity.set(0, 0, 1);
});

But I need to get Y velocity to increase Z velocity in useFrame above.

How can I do that? I checked obstacleRef and obstacleApi and found nothing related.

UPDATE: Event obstacleApi.velocity.subscribe method doesn't detect any change in velocity.

0

There are 0 answers