Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Ray/Sphere collision detection

This topic is 6355 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

Okay, don''t think I''ve seen this one out here before. Hope someone can help me. First of all: the question. Given a ray and a sphere, how can I tell if they are intersecting? "Ray" is a vector with a normal showing direction, "Sphere" is a vector and a radius. Now, to clarify, the problem: In my litle engine (if you could call it that) I have a fairly nice landscaping techniqe set up for what I hope will end up being a turn based RPG (think FF Tactics for the computer on hexagon shaped maps). Anyways, this routine dose a great job of rendering the land but now I need some way of telling my guys where to go. The most obvious answer is click on a point and have the character move there. I can handle pathfinding and such but I need to know what point the user is clicking on first. My idea was for each point on the map make a sphere around it with a radius of 10 or so. I calculate a ray going straight "into" the world from the screens current rotation and mouse position (which I''m pretty sure I can do). Then I see if the ray is intersecting any of the points "spheres" and move my little guy to that point. I just need to know if the sphere and ray are intersecting and I can do the rest. Anyone happen to have a good equation lying around? ----------------------------- Blue*Omega (Insert Witty Quote Here)

Share this post

Link to post
Share on other sites

  • 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!