Jump to content
  • Advertisement
Sign in to follow this  
Kurt-olsson

Am i missing something, can i sweep like this?

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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. =(

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!