# Am i missing something, can i sweep like this?

This topic is 1272 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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.

##### Share on other sites
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. Edited by slicer4ever

##### Share on other sites

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.

##### Share on other sites

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?

Edited by Waterlimon

##### Share on other sites

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. =(

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 9
• 33
• 16
• 11
• 10
• ### Forum Statistics

• Total Topics
634122
• Total Posts
3015636
×