import { useFrame } from '@react-three/fiber'
const Respawn = ({ ecctrlRef, setPos, levelPos }) => {
useFrame(() => {
if (ecctrlRef.current) {
try {
const { y } = ecctrlRef.current.translation()
if (y < 0) {
// this random hack ensures position is reset
setPos(levelPos.map(a => a + Math.random() * 0.02 - 0.01))
}
} catch (err) {
console.warn('error in getting ecctrl translation', err)
}
}
})
return null
}
export { Respawn }
And I'm getting this in the console:
Respawn.jsx:13 error in getting ecctrl translation Error: null pointer passed to rust
at I3.wbg.__wbindgen_throw (chunk-GZS6NCTV.js?v=4fa056a0:2477:13)
at 0057ee2e:0x14f24a
at 0057ee2e:0x14f257
at 0057ee2e:0x11b55b
at _AA.rbTranslation (chunk-GZS6NCTV.js?v=4fa056a0:1811:18)
at lA.translation (chunk-GZS6NCTV.js?v=4fa056a0:2650:26)
at Object.current (Respawn.jsx:7:41)
at render$1 (chunk-PEHQA6ZE.js?v=4fa056a0:17451:22)
at loop (chunk-PEHQA6ZE.js?v=4fa056a0:17474:19)
The player does respawn in the level so the code works mostly, but it's strange it's throwing the null pointer error.
Here's my component:
And I'm getting this in the console:
The player does respawn in the level so the code works mostly, but it's strange it's throwing the null pointer error.
Thanks.