Home   Help Search Login Register  

Author Topic: ai move to player (radius)  (Read 1357 times)

0 Members and 1 Guest are viewing this topic.

Offline sharkattack

  • Former Staff
  • ****
ai move to player (radius)
« on: 15 Dec 2007, 13:04:08 »
hi gang
having some trouble ... i want an enemy unit to move within a 50 m radius of the player

i can get him to move directly to the player  using
this move getPos player

what do i add ...  so that ai will move to a position within 50m of the player ??

many thanx in advance
"HOLY SARDINE" - see Shark-Attack meet his match

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: ai move to player (radius)
« Reply #1 on: 15 Dec 2007, 13:38:23 »
Code: [Select]
_dir = random 360;
unit_name domove [(getpos player select 0) + (50*sin(_dir)), (getpos player select 1) + (50*cos(_dir))];

or something like that.  :whistle:

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: ai move to player (radius)
« Reply #2 on: 15 Dec 2007, 13:40:49 »
Code: [Select]
_unit = _this select 0;
_target = _this select 1;
_radius = _this select 2;

_ang = random 360;
_rad = random _radius;
_pos = [(getPos _target select 0)+sin(_ang)*_rad, (getPos _target select 1)+cos(_ang)*_rad, 0];
_unit move _pos;

EDIT:  :whistle: :P

Offline sharkattack

  • Former Staff
  • ****
Re: ai move to player (radius)
« Reply #3 on: 15 Dec 2007, 15:57:30 »
thanx guys ...  :D
"HOLY SARDINE" - see Shark-Attack meet his match

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: ai move to player (radius)
« Reply #4 on: 15 Dec 2007, 22:34:10 »
and u cud even do it in just 1 line :P... like

unitname domove [(getpos player select 0) + (random 50) - (random 50),(getpos player select 1) + (random 50) - (random 50),0]

:D

LCD OUT

[edit]

P.S im kinda drunk... so if my maths or nything else is worng dont kill me :P
« Last Edit: 15 Dec 2007, 22:39:19 by LCD »
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta