Jump to content

Limit physic rotation of player when walking over ground.


Recommended Posts

Hi all


yesterday i started to test Phaser lib, i'm trying to create a demo with a player walking on top of a mountain, using p2, but using

player.body.fixedRotation = true;

Which doesn't let the player follow the path regarding its rotation.


Disabling this, cause the following behavior of the image attached:


The first idea is to use the update method and use something like:

player.angle = (180/Math.PI) * player.body.rotation;

I will have to check the current rotation angle and direction of the player and limit its angle but the body has to be fixedRotation = false.


There is a way to achieve this better, like getting the normal and using its angle with the ground to make always perpendicular the player to the ground?


Thank you in advance.


Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...