Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


ai movement


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Anddos   Members   -  Reputation: 537

Like
0Likes
Like

Posted 26 September 2012 - 02:03 AM

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.
:)

Sponsor:

#2 Ashaman73   Crossbones+   -  Reputation: 9744

Like
0Likes
Like

Posted 26 September 2012 - 03:35 AM

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
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
   else
	 // move into direction of next path
	 direction = normalize(current_wp - entity.position)
	...move for 1 frame
	end
end



Edited by Ashaman73, 26 September 2012 - 03:35 AM.

Ashaman

 

Gnoblins: Website - Facebook - Twitter - Youtube - Steam Greenlit - IndieDB - Gamedev Log





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS