Collision slightly walking into obstacles.

22 views
Skip to first unread message

Emanuele

unread,
Nov 10, 2015, 12:01:19 PM11/10/15
to HaxeFlixel
When the player is colliding with obstacles if I'm pressing the arrow keys he moves about 10px inside the wall, and as soon as I release the keys he gets pushed 10px backs properly.

The structure of the level is a Level FlxGroup which contains a walls FlxGroup and a Player FlxNestedSprite.

In the Player update function I'm first calling the movement function and then the super.update function, while in the Level class I'm calling the super.update function first and then the FlxG.collide between the walls and the player.

So it should be moving the player first, and then collide him out of the wall, but it seems that he can still walk slightly into the wall if I'm moving him.

I tried tracing the x and y position of the player after the FlxG.collide function, and they are always the same, even when on the screen he is moving slightly into the wall, so maybe the screen is drawn before the collision is checked?
Message has been deleted

Vasco

unread,
Nov 10, 2015, 1:49:32 PM11/10/15
to HaxeFlixel
Are you calling super.update() before FlxG.collide in the FlxState? I'm not sure if your Level class is a FlxState. What should happen is that the player's position is updated within super.update(), and then the collision test will correct it if the player is colliding.
Reply all
Reply to author
Forward
0 new messages