Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am trying to implement point and click movement in my game, but at the moment I am stumped about how I can select parts of a mesh for the player to walk to.

So what I have done is I have got a navigational mesh in my game. I can select points from it but what I want to do is be able to select the navigational mesh in real time and be able to tell the player where to go on the navigational Mesh, how can I achieve this?

I thought triangle-picking might be one way to determine which mesh I am selecting with mouse-unproject but I think I need a bit more accuracy than that, no?

How can I achieve point and click on a navigational mesh in real time?

share|improve this question
    
This seems like it could be helpful. link –  mwjohnson Sep 10 '13 at 0:59

2 Answers 2

If you use triangle picking, you only need to solve for a line/plane intersection test to find the point on the triangle that you clicked on.

Use the raycast as your line and treat the triangle as a plane.

share|improve this answer

In theory your navigation mesh should be fairly sparse with a few big triangles. Ray/triangle intersection is also fairly fast if you don't have many triangles. The best approach is likely to simply fire a ray from the camera through the cursor and see if it intersects any of the triangles from your nav-mesh, and if so, tell the player to move there.

share|improve this answer
1  
Don't forget you are casting a ray off the near plane of the camera, not off the camera's origin and normal. The placement on the near plane is based on the screen space coordinates of the mouse, etc. –  David Young Jun 11 '13 at 22:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.