OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: kernel_clink on 23 Feb 2004, 18:16:54

Title: Easy way to calculate distance?
Post by: kernel_clink on 23 Feb 2004, 18:16:54
Hi,

Im trying to get back into OFP mission making and my first little project is to make a virtual test range. I was wondering if there is a easy way to calculate distances ? or what is the easiest way to set targets at 'real' like distances, 100,200,400 meters ? from my shooter's position?

THanks in adv
Title: Re:Easy way to calculate distance?
Post by: icarus_uk on 23 Feb 2004, 18:31:30
To determine the distance between two objects you can use the distance command;

Object1Name distance Object2Name

Will return the distace between the two objects.

If you wanted to set targets at certain distances, you'd use the setpos command,

TargetObject Setpos [(Getpos Player Select 0) +100, Getpos Player Select 1, 0]

This line would set the named target object 100 metres east of the player unit.  Its easier if you want to set the distances in either north, east, sourth or west directions as you can just change the value of the offset (the +100 in this case) and move it to either the select 0 (east/west) or select 1 (north/south).

Moving it off in any other directions (north-east for example) would still be simple, it just requires some trigonometry.
Title: Re:Easy way to calculate distance?
Post by: kernel_clink on 23 Feb 2004, 20:06:54
Of course it had to be easy  ;)  Thanks, i remember using that a long time ago to spread out teams.....some of the rust is starting the shake off, thanks