pmndrs / ecctrl

🕹️ A floating rigibody character controller
MIT License
465 stars 49 forks source link

disableExternalRayForces prop #47

Open ChristopherTrimboli opened 2 months ago

ChristopherTrimboli commented 2 months ago

I was getting nasty errors like:

Uncaught RuntimeError: unreachable
    at 0057ee2e:0x11eb73
    at 0057ee2e:0x14b636
    at 0057ee2e:0x145389
    at 0057ee2e:0x1104bf
    at AA.rbApplyImpulseAtPoint (rapier_wasm3d.js:4555:14)
    at lA.applyImpulseAtPoint (rigid_body.ts:843:21)
    at Object.current (Ecctrl.tsx:1058:11)
    at render$1 (index-d98fd1c7.esm.js:1542:22)
    at loop (index-d98fd1c7.esm.js:1571:19)

It is a race condition if jump / move + update Floor / platform physics too quickly.

I have a static floor, that updates frequently, but I do not need the character to apply forces to the floor. In this case, ecctrl can safely remove all rayHits to the floor / platform.

Fixes the Rust crashing errors, still works as a character controller great, and general performance is also improved since bypassing much physics forces.

Downside is platforms / floors, IF dynamic, they would not get the cool: "trampoline bounce effect" like in ecctrl demo. However there is many apps that have fixed terrain / floors / platforms which rayHits become mostly bloat, so a prop disableExternalRayForces introduced so devs can configure how they prefer.