Neogene Posted January 31, 2015 Share Posted January 31, 2015 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 usingplayer.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 More sharing options...
valueerror Posted February 1, 2015 Share Posted February 1, 2015 so you want the player to always be rotated perpendicular to the surface ? normally a person walking up a hill still would not "rotate" at all.. the head would always point directly to the sky.. like in this example: http://test.xapient.net/phaser/tilemapexample/index-p2.html Link to comment Share on other sites More sharing options...
Neogene Posted February 5, 2015 Author Share Posted February 5, 2015 Yes but it not "correct" in the sample you linked the mountain is a diagonal without any curves, but in a game which uses a physic environment like the one i tested it's not the best looking solution. Link to comment Share on other sites More sharing options...
valueerror Posted February 6, 2015 Share Posted February 6, 2015 do you mean like this ?? http://test.xapient.net/phaser/hills/ Link to comment Share on other sites More sharing options...
Neogene Posted February 7, 2015 Author Share Posted February 7, 2015 @valueerror Thank you! it's like it should be, i'm studying the code to understand how you managed to do it! Link to comment Share on other sites More sharing options...
valueerror Posted February 8, 2015 Share Posted February 8, 2015 great to hear it is - of course - just a quick draft and needs a lot of tuning in my opinion... Link to comment Share on other sites More sharing options...
Neogene Posted February 12, 2015 Author Share Posted February 12, 2015 Yes, like the first start when touch the mountain jumps like a frog great to hear it is - of course - just a quick draft and needs a lot of tuning in my opinion... Link to comment Share on other sites More sharing options...
valueerror Posted February 12, 2015 Share Posted February 12, 2015 i'd love to see your final code - when it's ready Link to comment Share on other sites More sharing options...
Recommended Posts