Jump to content
Posted 20 May 2012 - 02:48 PM
Posted 20 May 2012 - 03:59 PM
I have never used this method before so I don't know if it works this way but couldn't you use a line collision check from point A where he starts and point B where he is after the movement, if the line collides you know you have a collision in the movement path move the player to that location and if you want check the collision as normal.
I have a collision checker method in my game that effectively checks the collisions between two objects. (Two nested for loops check each of the player's boxes against each of object b's boxes.) After the check, I have the player respond to the collisions. The problem however, lies in his speed. Because in one frame he could be moving up to 30 pixels (his terminal velocity), he can pass through an object and never have it be detected. What happens more often is that he ends up half in half out of a platform, activating 3 of his collision boxes. I've tried telling the player to automatically move up to rest on the platform, but that results in the player constantly jumping between a point inside the platform, and the point that I want him to be at. Any suggestions to solve this?
Edited by Moonkis, 20 May 2012 - 04:01 PM.
Posted 22 May 2012 - 01:59 PM
Sorry, that's what I meant. Every object has an array for rectangular bounding boxes. The platforms only have one bounding box. The player uses four so I can tell which side is being hit.
wouldn't it suffice with only one box for the platform
Posted 22 May 2012 - 04:38 PM
Posted 22 May 2012 - 04:52 PM
Posted 22 May 2012 - 07:35 PM
This is part of the problem I was having. My character can move fast enough (downward) to move completely through a platform in one frame and it seems your method wouldn't check for that. I can always solve this by making all platforms have a minimum height equal to his terminal velocity... actually I think I'll go with that. I honestly just needed to talk that one out.
If there is no overlap, then there is no collision…nothing more to do.
Posted 23 May 2012 - 09:28 AM
If you use the box overlap first as I suggested above, you may still get that problem though, which will arise if Box A moves past Box B entirely – there’ll be no overlap, so you’ll not bother doing the sweep.
Edited by freakchild, 23 May 2012 - 10:06 AM.