Hi, I have a problem which is that my character should stop it’s gravity when it overlaps with the ladder. I tried to set ignoreGravity but it isn’t helpfull. Somebody got an idea how to stop my character gravity to climb?
Can you post a snippet of your code? Maybe the callback function for the overlap detection with the ladder?
this.matter.world.on('collisionstart', (event: any, bodyA: any, bodyB: any) => {
if (bodyA.gameObject?.tile?.properties.type == 'ladder') {
this.player.player.setIgnoreGravity(true)
this.player.player.setAngularVelocity(0)
eventEmitter.emit('playPlayerAnimation', 'climb')
}
});
this.player.player.setAngularVelocity(0)
would refer to the object body’s rotation. I believe you’re looking for this.player.player.setVelocity(0)
. From what I can tell, it seems your player is indeed ignoring gravity when they’re overlapping the ladder, but they’ve still got the velocity they had when they entered the ladder’s space. See if that works, otherwise it looks good to me!
I don’t know why setVelocity(0)
is not working, but setVelocity(0,0)
is working. I mark this as a solution.