Collision issue

  • Hello guys,
    I have a bug I can't fix by myself :/ there is a collision bug in my project but let me explain first.

    I got boxes in my game which are affected by gravity, they collide with each other and the player is able to mount on those boxes and push them (see picture below). The problem I have is that when I jump on any box, they are swallowed by the ground even though they are colliding with it..;

    My current code for collisions is the following :

    override public function update(elapsed:Float):Void
    	FlxG.collide(player, boxes);
    	FlxG.collide(player, map);
    	FlxG.collide(boxes, map);
    	FlxG.collide(boxes, boxes);

    What I have already tried is to change the position of the super.update(elapsed) without success, and change the order of the collision lines... I already put drag on y on both the player and the boxes...

    The bug is looking something like that :

    Any help is welcome :)

  • you need immovable = true; at the boxes class.

  • @galoyo I still need the player to be able to move the boxes

  • you could use startY = y at function new and then at function update put y = startY when player is above box.

  • you could set immovable = true; when player collides with object floor and set immovable = false when colliding with object wall.

  • There is an argument in FlxG.collide() for callback function. You can try reseting the undesired velocity of the box inside the callback.

Log in to reply

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