Is it possible to avoid objects sliding down on slope platform?

Hello everyone
Is it possible to avoid objects sliding down on the slope platform?
Here is my project:

https://playcanvas.com/editor/scene/1590955

I using Rigidbody
I has been set up applyImpulse to zero when player not move, but not work

Player.prototype.update = function(dt) {
    if(this.app.keyboard.isPressed(pc.KEY_A)){
      this.entity.rigidbody.applyImpulse(-this.speed, 0, 0);  
    }
    if(this.app.keyboard.isPressed(pc.KEY_D)){
      this.entity.rigidbody.applyImpulse(this.speed, 0, 0);  
    }
    if(this.app.keyboard.wasReleased(pc.KEY_A) || this.app.keyboard.wasReleased(pc.KEY_D)){
       this.entity.rigidbody.applyImpulse(0, 0, 0);  
    }
    
};

Keyboard A to move left
Keyboard D to move right

Thank you very much

Hi @supsersuperman,

That happens because friction on your main player is set to 0, so even though friction on the platform is set to 1, the player will slide down.

You can set it to 1 on the player rigid body component, though you will need then to update your movement logic to calculate the forward vector based on the direction of the platform. Otherwise the player will be unable to climb up that slope.

1 Like