This might not help, and it''s been like 100 yrs since I played Super Mario, but...
I seem to remember that as long as I was moving in an upward motion, the block would break even if I''m only hitting the corner. As long as my horizontal position was under the block even a little, it counted as a bottom collision.
Also, when moving in a downward direction, it seemed like I would land on a platform as long as my horizontal position was past the edge of it even a little. Again, it didn''t matter that it was on a corner.
Maybe you have to prioritize your checks. If moving upward and you collide with a block, check for a bottom collision first, then a side collision. If moving downward, check for a top collision first, then side. If you hit a corner, you''re always checking for top/bottom first. If you collided with the block, but it wasn''t a top/bottom collision, it was a side collision. Base the action you take on the type of collision (top/bottom/left/right).
2D Collision Detection Problems!!!
Everyone keeps mentioning ray casting and I don''t know exactly what it is. I can''t find any articles on using it for collision detection. Can anyone enlighten me?
Stay Clausal,
Red Sodium
Stay Clausal,
Red Sodium
ray casting is mostly a fancy word. it''s like doing collision detection using segmemts (two end points), but with a ray (pos, dir, with possibly a maximum length), so only slightly different.
You can extend the segment intersection test to do swept volumes collision tests, which is another fancy word, that''s basically your normal collision stuff, but with also using the direction and speed of memvent in the collision test to get more accurate results. Obviouly, the tests become more complicated, since you through some other stuff in the calculations.
there are advantages using, say a segment for a travelling bullet, so that you can catch events when the bullet goes so fast it teleports through objects from one frame to another. A segments would detect that better.
For example, for a travelling bullet the ray-cast in collision detection can be setup like this.
Ray.Pos = Bullet.Position
Ray.Dir = Bullet.Direction;
Ray.MaxLength = Bullet.Speed;
or
Segment.P = Bullet.Position;
Segment.Q = Bullet.Position + Bullet.Direction * Bullet.Speed;
then you do
if (Intersect(Ray, Enemy.BoundingBox)) Enemy.Destroy();
or
if (Intersect(Segment, Enemy.BoundingBox)) Enemy.Destroy();
You can extend the segment intersection test to do swept volumes collision tests, which is another fancy word, that''s basically your normal collision stuff, but with also using the direction and speed of memvent in the collision test to get more accurate results. Obviouly, the tests become more complicated, since you through some other stuff in the calculations.
there are advantages using, say a segment for a travelling bullet, so that you can catch events when the bullet goes so fast it teleports through objects from one frame to another. A segments would detect that better.
For example, for a travelling bullet the ray-cast in collision detection can be setup like this.
Ray.Pos = Bullet.Position
Ray.Dir = Bullet.Direction;
Ray.MaxLength = Bullet.Speed;
or
Segment.P = Bullet.Position;
Segment.Q = Bullet.Position + Bullet.Direction * Bullet.Speed;
then you do
if (Intersect(Ray, Enemy.BoundingBox)) Enemy.Destroy();
or
if (Intersect(Segment, Enemy.BoundingBox)) Enemy.Destroy();
So did you come up with solution to your problem? I''m having the same problem and would love to see some example code that works properly.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement