pmndrs / ecctrl

🕹ī¸ A floating rigibody character controller
MIT License
565 stars 65 forks source link

enabledRotations not working in NextJs? #89

Closed JoaoMPdS closed 3 months ago

JoaoMPdS commented 3 months ago

So I'm making a 3d game using NextJs, react three fiber, rapier, and ecctrl and I've encountered a weird issue. It looks like the "enabledRotations" prop in the Ecctrl tag is at first fully ignored (it allows rotation on all axis, no matter what I input there) until I save and use hot reload and it starts working.


These are the properties that I'm using on my controller: // Camera Related \ camInitDis={-.01} camMinDis={-.01} // camMaxDis={-.01} // uncomment if on production disableFollowCam= {false} camFollowMult={100} camLerpMult={1000}

// Character Stats \ maxVelLimit={2} jumpVel={2} turnVelMultiplier={1} turnSpeed={100}

// Character Appearance \ capsuleRadius={.5} capsuleHalfHeight={.5}

// Misc \ mode="CameraBasedMovement" autoBalance={true} enabledRotations={[false, true, false]} wakeUpDelay={200} dampingC={0.05} floatingDis={.75} animated

ref={controllerRef}


Any help would be greatly appreciated! 😄

ErdongChen-Andrew commented 3 months ago

enabledRotations will be overridden by autoBalance. If you want to lock the rotation, just set autoBalance to false

JoaoMPdS commented 3 months ago

The issue is that, as stated here, AutoBalance will also make it so you can not access the body's translation. Is there a way to have AutoBalance disabled and also be able to get the translation of the model?

ErdongChen-Andrew commented 3 months ago

You mean rotation? You can get the rotation from the character model using: characterModel.getWorldQuaternion()

JoaoMPdS commented 3 months ago

After making quite a few adjustments to my code and implementing your idea, the issue seems to be fixed! Thank you so much for the help! 😄