OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: sharkattack on 15 Dec 2007, 13:04:08

Title: ai move to player (radius)
Post by: sharkattack 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
Title: Re: ai move to player (radius)
Post by: bedges 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:
Title: Re: ai move to player (radius)
Post by: Mandoble 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
Title: Re: ai move to player (radius)
Post by: sharkattack on 15 Dec 2007, 15:57:30
thanx guys ...  :D
Title: Re: ai move to player (radius)
Post by: LCD 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