Collision issue

  • Hi there !
    I need your help. I explain. I started programming a basic 2D platformer just to train with the framework and I’m having a collision issue which I don’t actually understand. I have a tilemap which I load with .loadFromCSV with a csv file. I have a player which for now just moves in all direction and I manage collisions between these two objects with FlxG.collide and then the up and down tile collisions works but the wall collision (left and right) doesn’t ! When the player collide the tile in the right or left the player goes up until there is a empty tile. I tried changing the tile properties but nothing worked. Have you any idea how can I fix that ?

  • It sounds to me like the player is getting too far into the "wall" tile before the hit test occurs.

    My guess is that the call to FlxObject.separateX() is finding 0 overlap and so it skips that and goes on to separateY(). You could maybe confirm that with some trace() lines.

    How big is your player asset compared to the tile size? Maybe try making the hit box slightly bigger or smaller by a few pixels so that it doesn't match a tile exactly during a hit test.

    Edit: You could also try moving the player more slowly (in increments less than your tile-size), just to see if the framework picks up the collision better that way.

Log in to reply

Looks like your connection to HaxeFlixel was lost, please wait while we try to reconnect.