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 { KeyState.keys.update(); FlxG.collide(player, boxes); FlxG.collide(player, map); super.update(elapsed); 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
atfunction new
and then atfunction update
puty = startY
when player is above box.
-
you could set
immovable = true;
when player collides with object floor and setimmovable = 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.