You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello I am trying to get live position of the controllers to attach an object to them.
Currently I am using the useControllers() hook, it works great at getting the position and rotation data but the values won't update as the controller moves
Hi, when you pass position like in that example it will only set it during a render (basically once). So you need to synchronize controller position and box position every frame. For that you can use useFrame hook. It will execute a function on every frame. It should look something like this:
constref=useRef()// Reference for the box instanceconstleftController=useController('left')useFrame(()=>{// Don't forget to check this, controller may be disconnectedif(leftController===undefined)return;ref.current.position.copy(leftController.controller.position)ref.current.rotation.copy(leftController.controller.rotation)});return<Boxref={ref}/>
Hello I am trying to get live position of the controllers to attach an object to them.
Currently I am using the
useControllers()
hook, it works great at getting the position and rotation data but the values won't update as the controller movesThe text was updated successfully, but these errors were encountered: