gnl Posted November 18, 2016 Share Posted November 18, 2016 I'm new at using Phaser and I'm facing an issue that I would appreciate your help if you could guide me on how to solve it. I want my character to move on the play area if and only if is attached to a surface either that being a side, floor or ceiling of a sprite. I have managed to check if he is attached to these edges but the problem happens when the velocity of the character causes it to move past the end of the edge and stand on a point that is further away from the corner of such an object. To make things a little more clear, imagine a rectangle of 100 pixels wide and 50 pixels tall and the character has to move on all edges of this rectangle without going over the 100th pixel in the x dimension nor the 50th pixel in the y dimension. If the velocity is too high in either direction then when the update method will get called the position of the character will be past the limiting positions. So the question is, is there a way to check ahead the attaching edge based on the velocity of the character in order to make sure that when the next update function call happens the character will still be attached to the edge? Thanks Link to comment Share on other sites More sharing options...
drhayes Posted November 18, 2016 Share Posted November 18, 2016 There is but it greatly depends on what that surface is. Is it a tilemap? Another sprite? What physics system are you using? Link to comment Share on other sites More sharing options...
gnl Posted November 18, 2016 Author Share Posted November 18, 2016 Hi, I'm using ARCADE physics and the surface may be either a tile or another sprite. I believe that if I solve it for one kind of surface I'm also going to be able to solve it for the other too! Link to comment Share on other sites More sharing options...
Recommended Posts