Jump to content
  • Advertisement
Sign in to follow this  

ai movement

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

ok what i want do is make my ai rotate stop , make a direction to move from the rotation , move in that direction until he reachs the point and then do this over and over again , i know how todo each thing , i just cant keep it going in the main thread, i am sure i am going to need alot of bools.

Share this post

Link to post
Share on other sites
You are talking about following a path ?
Then you could do it like this:

// start to follow a path
entity.path = {waypoint1,waypoint2,....waypointn}
entity.path_index = 0

// main loop
if entity.path_index<entity.path.length then
current_wp = entity.path[entity.path_index]
if distance(current_wp,entity.position) < threshold then
// take next index
entity.path_index += 1
// move into direction of next path
direction = normalize(current_wp - entity.position)
...move for 1 frame

Edited by Ashaman73

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!