-
-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KinematicCharacterController.setMaxSlopeClimbAngle is not working #274
Comments
Hi! Can you provide more informations on your setup? In particular, the piece of code where you initialize and call the character controller’s methods, and how you apply it to the corresponding rigid-body. What is the geometric shape of your character? |
here's the code where I create and move the character controller create() {
const RAPIER = pc.app.rapier;
const offset = 0.01;
this.controller = this.world.createCharacterController(offset);
this.controller.setMaxSlopeClimbAngle(0);
const rigidBodyDesc = new RAPIER.RigidBodyDesc(
RAPIER.RigidBodyType.KinematicPositionBased,
);
this.body = this.world.createRigidBody(rigidBodyDesc);
const position = this.entity.getPosition();
this.body.setTranslation(position);
const colliderDesc = RAPIER.ColliderDesc.capsule(0.8, 0.8);
colliderDesc.setCollisionGroups(GROUPS.PLAYER);
this.collider = this.world.createCollider(colliderDesc, this.body);
this.collider.userData = { userID: this.app.userInfo.userID, isPlayer: true, isSelf: true }
this.entity.rigidBody = this.body;
this.world.character = this;
},
move(input, dt = 0.01666) {
if (!this.body) return;
const direction = input.inputMove;
const current = this.body.translation();
this.vector.x = direction.x * input.speed * dt;
this.vector.y = 0;
this.vector.z = direction.z * input.speed * dt;
this.controller.computeColliderMovement(this.collider, this.vector, null, GROUPS.BULLET | GROUPS.PLAYER);
const correctedMovement = this.controller.computedMovement();
this.vector.x = current.x + correctedMovement.x;
this.vector.y = current.y + correctedMovement.y;
this.vector.z = current.z + correctedMovement.z;
this.body.setNextKinematicTranslation(this.vector);
const newPosition = this.body.translation();
this.entity.setPosition(newPosition.x, newPosition.y, newPosition.z);
}, |
Small update. I was able to reproduce the issue. This is mainly caused by the fact that there is no gravity being applied |
I have rapier simulations on both the server and the client. I try to run them in sync with each other. Determinism helps, but when I apply gravity, I start having issues - the collision resolution with the ground seems very erratic and unpredictable, and the more gravity you apply, the more the two simulations diverge from each other. So it required me to apply too much server reconciliation, which was not ideal. I found the only solution was to stop applying gravity, but then this bug happened. I kinda solved it by raycasting the ground and applying gravity only if the character was getting higher, but yeah, that sucks. Would be great if it is fixed and I could use setMaxSlopeClimbAngle to handle this. |
Same result with @khudiiash, continuous apply gravity simulate into KCC make rigid body movement erratic and unpredictable (sometimes pass through the ground, loss collision event when 2 obstacles shared same edge and unacceptable is even when the ground flat, character sometimes jump a little bit and fall down again...) |
I have a character controller and a trimesh as terrain. The terrain is mostly flat but has some heals and walls
The character controller climbs on top of even the steepest hills, and the setMaxSlopeClimbAngle value does not change a thing.
rapier3D, v0.13.1, javascript
The text was updated successfully, but these errors were encountered: