Why isn't my position updating in ref.current.position

Viewed 310

I am trying to change the camera position in my r3f scene based on a mesh position. I am also using r3f/cannon for physics and ref positioning. Whenever i try and retrieve the position of my body, the ref thinks it hasnt changed and i just get the initial set position. Why can't i retrieve the updated position? Here is a snippet of the ref and useFrame

  const [ref, api] = useSphere(() => ({ args: [5,10,10], mass: 1, position: [0, 15, 0], material: { friction: 10}, ...props }))
  
  useFrame(({clock}) => {
    console.log(ref.current.position)
  })

It only ever logs the initial position, even if the object is moving around

1 Answers

The correct way to access the position will be ref.current.position

Related