TheSisb Posted October 21, 2015 Share Posted October 21, 2015 My game: http://antipeasantry.com/PhaserGame/index.html If I move my character to the bottom left corner of the world and start banging into the edge then moving back out while (Somewhat) wildly mashing on directional keys, the sprite begins to rotate ever so slightly. I want to keep it locked to 8 directions: left, topleft, top, topright, right, bottomright, bottom, bottomleft and avoid any rotations. Any advice is appreciated! Thanks Quote Link to comment Share on other sites More sharing options...
TheSisb Posted October 21, 2015 Author Share Posted October 21, 2015 Image of rotated character: http://imgur.com/mg9GIhK Quote Link to comment Share on other sites More sharing options...
mattstyles Posted October 21, 2015 Share Posted October 21, 2015 I can replicate your problem, looks like angular velocity has been added to your physics body, and it also looks like there is no damping force to stop it. Further, it looks like maybe the problem is the collision. When objects collide friction (and some other stuff) causes angular forces to be exerted upon them, these forces are usually dissipated by damping forces in simulations. So, I think a couple of things, or a combination of them, might help you out: Whack up the `angularDamping` to 1 (I think that is max), which means thats any angular momentum is immediately damped to 0.Check out your `contactMaterials`, the contact materials set some factors of what happens when different materials collide, setting friction to 0 or 1 (min or max, I cant remember which way round you need). Oh, for some reason I assumed you were using P2 for physics, Phaser supports other physics engines, I only have working knowledge of p2 but its quite possible the theory remains for the other 2 phaser implements (ninja and arcade I think) Quote Link to comment Share on other sites More sharing options...
TheSisb Posted October 22, 2015 Author Share Posted October 22, 2015 I'll try this out! Thanks for the advice Quote Link to comment Share on other sites More sharing options...
TheSisb Posted October 22, 2015 Author Share Posted October 22, 2015 This example helped solve it: http://www.phaser.io/examples/v2/p2-physics/basic-movement Key lines:sprite.body.setZeroDamping();sprite.body.fixedRotation = true; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.