-
Hi, considering Rapier is deterministic (if this is relevant), is it possible to save the trajectories of different scene objects and then invert the animation? For example a ball bounces down then comes to a stop, in inverted time, it starts from a resting position on the floor then starts bouncing higher and higher until it goes back to initial position. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey, There's no way to play the simulation in reverse, but you could always use the API to record the RigidBody's transform and velocity, to more or less return it to a previous state. For instance: const timeline = []
const recording = true
const Object = () => {
const ref = useRef<RigidBodyApi>(null)
useFrame(() => {
if (recording && ref.current) {
const translation = ref.current.translation()
const rotation = ref.current.rotation()
const linvel = ref.current.linvel()
const frame = { translation, rotation, linvel }
timeline.push(frame)
}
})
return <RigidBody ref={ref} ... />
} You can use those values to "play" the timeline backwards. |
Beta Was this translation helpful? Give feedback.
Hey,
There's no way to play the simulation in reverse, but you could always use the API to record the RigidBody's transform and velocity, to more or less return it to a previous state.
For instance:
You can use those values to "play" the timeline ba…