Jump to content
  • Advertisement
Sign in to follow this  
boboS

follow mouse

This topic is 3690 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 wondering how to make an object on a map (RTS game) can follow the mouse position but move over the terrain. The simplest solution seems to pick a ray to see if it interesects a triangle from a grid. Isnt that slow ?

Share this post


Link to post
Share on other sites
Advertisement
You could look into octrees to speed it up. Yes raycasting an entire terrain is slow, but if it's only one ray then it's not too bad.

Alternativley there's probably an algorithm you could use to find the tile the ray hits. You know where it starts in world space (based on where your camera is), and you know the furthest away tile you could be pointing at (based on the minimum height of the terrain and the current view trajectory), so you could possibly write some code to check all tiles between the last possible tile and the camera.

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!