ecctrlRef.current.translation() causes null pointer
Open
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 797
- Forks
- 98
- Avg merge
- 8m
- Merged PRs (30d)
- 1
Description
Here's my component:
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.
Thanks.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the Respawn component shown in the report and inspect the ecctrlRef lifecycle around useFrame and translation(). Trace when the referenced physics object becomes invalid, then verify that the respawn behavior no longer emits the null-pointer error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react
- Domain
- frontend, game-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100