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

Capsule line intersectionpoint only

This topic is 1241 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 have made a capsule by making two circles and two lines between them (on the edges)

I use lineintersection and closest point to find out if the capsule intersects any lines, this works perfect and i get the intersectionpoint on the lines and where the closest point to the sphere is.

My problem is, i cannot get the circles intersectionpoint with radius. I have tried cutting velocity according to distance etc but its only working 95% correctish.

Is it possible to get the circle intersection from the capsule intersection point?

Share this post


Link to post
Share on other sites
Advertisement

Maybe someone else will but I'm definitely not quite understanding your question. Could you give more details or post a diagram?

 

I implemented capsule collisions once.. to the best of my memory, to determine the closest point on a line to a capsule, I checked the distance between the two center center points to the line (point to infinite-line distance calculation) and then the distance between the line and the straight section of the cylinder (infinite-line to infinite-line distance calculation), and then projected the resulting closest point onto the line segment connecting the sphere center points to see if it was inside the cylinder portion. I had some simple logic to determine which of the 3 options was closest.

 

Hope that's somewhat helpful.. if not, please post more details.

Share this post


Link to post
Share on other sites

So you're intersecting a line and a capsule? You should represent the capsule with two points and a radius. Then you can do closest point between two lines calculation, and then use the radius to see if there was penetration. Getting a point of collision is pretty trivial since you have the penetration depth + axis of minimum separation via closest points.

Share this post


Link to post
Share on other sites

I did some test with two points and 3 rays that were traced for collision.

I ended up with just shooting one ray for my solution and i also didnt need to have the exact position of collision,

this is just to prevent the player from going through walls at great speeds. 

 

It ended up working great with just line-line intersection checks and then cut the velocity with the time (vel / distance of intersection) - some small value to be safe.

I forgot to say this is only in 2D.

 

thanks for the help! smile.png

Edited by KurtO

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!