Jump to content


Photo

Getting AI to walk away from player


  • Please log in to reply
3 replies to this topic

#1 dooley05

dooley05

    GMC Member

  • New Member
  • 6 posts

Posted 30 July 2012 - 08:43 PM

Basically my problem is that I have an archer that I want to follow the player but stays a distance away from it because otherwise it'd be a pretty terrible archer. Ive got it to do almost everything I want it to but for some reason when it walks away from the player it seems to be attracted to the top left hand side of the player meaning that when its at the bottom right of the player, instead of walking down and right it almost circles around the player towards the top left. This is the code im using in the archers step event to make it walk away from the player:

if target_distance < (range/1.3)-32{
    dir = target_direction;
    mp_potential_step_object(lengthdir_x(range,point_direction(target_nearest.x,target_nearest.y,x,y)), lengthdir_y(range,point_direction(target_nearest.x,target_nearest.y,x,y)),move_speed,par_avoid);   //try to stay a distance from the target 
    mp_potential_settings(30,15,range,0);}


Ive tried different ways of getting it to walk away such as using motion_set() instead of mp_potential_step()
and having the point_direction go from the archers x to the players x and adding 180 but everything I've tried seems to have the exact same result
I cant think why it seems to be so attracted to the top left and running out of ideas...

Edited by dooley05, 30 July 2012 - 08:49 PM.

  • 0

#2 Desert Dog

Desert Dog

    GMC Member

  • Global Moderators
  • 6409 posts
  • Version:Unknown

Posted 31 July 2012 - 10:57 AM

You may be wanting x+lengthdir_x, and y+lengthdir_y, etc etc.
  • 0

#3 dooley05

dooley05

    GMC Member

  • New Member
  • 6 posts

Posted 31 July 2012 - 01:06 PM

ARGH I hate it when a solutions SO SIMPLE when you spend ages trying to solve it
Thank you so much
  • 1

#4 Desert Dog

Desert Dog

    GMC Member

  • Global Moderators
  • 6409 posts
  • Version:Unknown

Posted 31 July 2012 - 08:04 PM

ARGH I hate it when a solutions SO SIMPLE when you spend ages trying to solve it
Thank you so much

Forgetting the x/y+ has tripped me up in the past, too. :tongue: Good luck!
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users