1

I have a sprite which is a member of a FlxTypedGroup. I check collision with another typed group in the update loop like so:

FlxG.collide(groundCollisionGroup, playerGroup);

This for the first few seconds of the game (roughly about 10 seconds from what I timed, but it is not consistent). After the first few moments of the game, the collision detection seems to just drop off and my player phases through the floor. I'm not sure what is causing this but I've tried adding an updateHitbox call to the update loop for my ground sprite since the camera is constantly scrolling.

groundCollisionGroup.forEach(function(gc)
{
    gc.x = FlxG.camera.scroll.x;
    gc.updateHitbox();
});

I also tried switching the collide method with a pixelPerfectOverlap method, however this also did not work

if (FlxG.pixelPerfectOverlap(player, groundCollision))
{
    player.acceleration.y = 0;
}
else
{
    player.acceleration.y = 500;
}

How can I keep collision consistent even when the camera is scrolling?

emoore
  • 314
  • 2
  • 11

0 Answers0