Jump to content
  • Advertisement
Sign in to follow this  
Kenster

Closest Point within a Radius...

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

I've spent a few days not trying to find a solution to a problem I am attempting to fix. Basically, when you are in an MMORPG you don't want to run to the direct NPCs location during an attack. You want to run the closest point within the Radius of your attack. Does anyone have a suggested formula for this? This is what I have. http://phpfi.com/322913 Thank you,

Share this post


Link to post
Share on other sites
Advertisement
The closest point on the circle is on the line between you and them. Just figure out the vector from them to you, normalize it, multiply it by the radius, and add the result to their position. That's it.

Share this post


Link to post
Share on other sites
Sneftel post the solution faster then me... The only thing I want to add is that in a MMORPG there are several skills and attacks and it can be difficult to know what the player want to do. What if you move the player near the NPC and the player want to cast a skill from distance?

Share this post


Link to post
Share on other sites
That easy, in the Method that returns a Point3D, I state the Radius of the skill. So it knows how far away the point should be.

Just weather the formula I just made works, still testing.

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!