Advertisement

Am i missing something, can i sweep like this?

Started by July 28, 2015 08:48 PM
3 comments, last by Kurt-olsson 9 years, 6 months ago

Hi.

I am thinking of a way to sweep polygons and rectangles against another polygon and get the Time of Impact.

If i draw lines between the vertexes startposition and endpositionof the polygon (or rectangle) and test those lines for intersections of the other polygon (or rectangle). If i then take the intersection point and compare it to the length of that line, that will give me time of impact.

It has of course be the earliest time of impact compared with all the intersections.

Can i really do it like this? It would be great, because then i can only do line-line intersection test between the vectexes of the shapes.

i submitted a file to illustrate this better.

I am using a sphere in my game now, and i dont think it works with my character.

there is a problem with this method: missing small objects. what happens if object B is small enough to fit between your raycasts?
it's an idea i toyed with before, but imo it has potentials for missis.
Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.
Advertisement

Yeah, you could try to kludge it by also including the center point, but there is still lots of potential for misses. It's easier with spheres, as you basically doing a capsule test for the sweep.

This only covers vertex-edge collisions. You also need to do the same from the perspective of object B (as if object B was moving toward A), to get edge-vertex collisions as well.

You cant really have edge-edge collisions in 2D without intersecting the shapes somehow (might be a problem) and vertex-vertex will probably work somehow so maybe this will do?

o3o

Thanks for all replies.

Yeah, i think i have to look at the more traditional AABB, OBB intersections techniques.

Now i am starting to read up on Minkowskis sum, that seems to be very nice way for handeling polygons of all shapes.

If i can just add and use the algorithm right it should be easy to cast a ray and get the intersection point as well.

I really got it to work with the Sphere, but it is not good in 2D scrolling game.

Now i want to use a rectangle instead. =(

This topic is closed to new replies.

Advertisement