I am trying to figure out how to do the mouse-click movement effect in my project. Right now my character (3rd person view) works just fine using the w,a,s,d controls. But instead of those controls, I want the player to be able to point where he/she wants to go, and then clicks and the player will automatically go to that spot.
Similar to Archlord, Wow, etc...(at least I think WoW has that type of movement)
Can anyone point me in the right direction or help me out with this? Thanks in advance...
asked Dec 19 '09 at 08:00 PM
Sounds very much like you need to look at "Pathfinding" solutions.
It's relatively trivial to get the world position on your terrain which corresponds to where the user clicked the mouse - see the Collider.Raycast docs for more on this - that page actually gives the following example using mouse clicks:
The more complex part is what to do once you have this destination point. You will rarely want the character to move in a direct line straight there because you'll have buildings, trees, walls, etc in your way. This is where pathfinding algorithms come into play.
This has already been covered on Unity Answers, so for more information about pathfinding solutions for Unity, check this link which will give you useful answers from this site tagged with pathfinding:
answered Dec 19 '09 at 09:42 PM