At 9/20/16 02:37 PM, SkyFire2008 wrote:
At 9/20/16 01:40 PM, GeoKureli wrote:
doesn't seem buggy
Try jumping, when standing like this, it will move you to the right.
FIrst off, it's really hard to get up there, whenever I make it up there I end up falling off the right side.
As for the issue, it seems like it's happening because when you jump you're embedded in the left tile, and you're overlapping in the Y axis more than the X, and the code resolves the smaller one. it's also doing collision detection/resolution per tile, meaning it resolves 1 collision before moving onto the next one.
Your current flow is to move the player according to its velocity, check overlap, resolve. I recommend checking collision of where it's going to be, before moving it, determine which tile collision happens first (where the frame start time is t=0 and the next frame is t=1) then move the players position based on the time of that collision. pos += velocity * t. that way the position the collision resolves to is always the original direction they were traveling
EDIT: for instance: if the wall is 5 pixels above your starting point, and your velocity is 10, t=0.5. so pos += velocity * 0.5. and you check all tiles for the lowest t (earliest collision) and use that t value