Editors Depot - Mission Editing and Scripting > ArmA - Editing/Scripting General

Move tanks 100m in front of player.

(1/1)

The-Architect:
I have some tanks that I would like to move to 100m in front of my position via radio command. What lines should I use in my script?

h-:
I guess the command moveTo would be useful.

SoldierEPilot:
Think on your sins and cosins :D


--- Code: ---_r = 100;
_pos = getPos player;
_dir = getDir player;
_x = (_pos select 0)+_r*sin _dir;
_y = (_pos select 1)+_r*cos _dir;
CmdTank moveTo [_x, _y];
--- End code ---

The-Architect:
LMAO, that's maths right?

How do I add this to a handy little script?

h-:
That already is a handy script :P
(although for performance's sake it's not necessary to declare so many variables).

If your tank group's leader tank is MyTank, add the following to your radio trigger on act field:

--- Code: ---MyTank moveTo [(position player select 0)+100*sin(direction player), (position player select 1)+100*cos(direction player)]
--- End code ---
.

That makes them drive to 100 meters in front of the player (or more accurately where player's chest is pointing).
Of course you need to account the horrible driving capabilities of the AI and they might not ever get there..

Navigation

[0] Message Index

Go to full version