Tilemap Collision - Sprite falls through tiles
-
Hi,
I have created a tilemap using Tiled Editor. The Player sprite moves around quite nicely on the tilemap. However, if the user moves too fast, it falls through the tiles without detecting any collision. Here is a video of it happening (It happens at the 10th time): https://imgur.com/a/Ry0HVqg
Here is my update method:
override public function update(elapsed:Float) { player.update(elapsed); if (FlxG.keys.anyPressed([X])) { player.setPosition(100, 100); } super.update(elapsed); FlxG.collide(collisionLayer, player); }
Is there some better way to do this as to avoid this issue?
-
Maybe play around with the
SEPARATE_BIAS
value: https://api.haxeflixel.com/flixel/FlxObject.html#SEPARATE_BIAS
-
I found the issue. I was calling the player.update() method during the state update. I didn't know all objects added to the state have their update called automatically. Removing the player.update() method fixed the issue.
-
Oh, yeah, objects being updated more than once could cause all sorts of issues.