Skip to content
Discussion options

You must be logged in to vote

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 ba…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@quacrobat
Comment options

Answer selected by quacrobat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested
2 participants