Closest Point within a Radius...

Started by
2 comments, last by Kenster 15 years, 10 months ago
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,
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.
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?
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.

This topic is closed to new replies.

Advertisement