Home   Help Search Login Register  

Author Topic: Distance from position  (Read 1439 times)

0 Members and 1 Guest are viewing this topic.

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Distance from position
« on: 06 Oct 2002, 21:28:48 »
Is dere ny command dat calculates da distance from unit 2 position (da 1 dat u get wid da getpos command) ?

cus da distance command works only wid objects

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

seanver

  • Guest
Re:Distance from position
« Reply #1 on: 06 Oct 2002, 21:47:17 »
My god! your message is a gibberish.  :hmm:

 Try to use a gamelogic at the position you want, just get the position with the getpos command, and then set the position of the gamelogic with setpos.

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:Distance from position
« Reply #2 on: 06 Oct 2002, 22:15:16 »
i know how 2 use GLs but dat dont solve my prob - im usin dis 2 remember positions of a created/deleted units if i put GLs instead of em it just replacin it wid oder 1 so it dont help me - it wil keep da unit count da same  ;D

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

walker

  • Guest
Re:Distance from position
« Reply #3 on: 06 Oct 2002, 22:22:46 »
Cough From the unofficial command manual Cough

Command :
Distance
 
Description :
Used to find the distance between 2 units/objects.
 
Syntax :
Name1 Distance Name2

Name1 is the name of a unit or object.
Name2 is the name of a second unit or object
 
Returns :
Distance in meters between Name1 and Name2.
 
Example:
?(MyGuy Distance MyLeader > 300):MyLeader SideChat "Get over here!"
 
or

thedistanceyouwant = MyGuy Distance MyLeader

 :)

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:Distance from position
« Reply #4 on: 06 Oct 2002, 23:03:46 »
Quote
cus da distance command works only wid objects

i need 2 calculate da distance between unit and a position(da 1 dat i get with getpos objectname) - not object and object :P

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:Distance from position
« Reply #5 on: 07 Oct 2002, 01:16:41 »
You could throw a couple of gamelogic's down on your position(s)... eg to get the distance between two positions:

bob = "logic" createvehicle [ position ]
sid = "logic" createvehicle [ other position ]
dist = bob distance sid
"deletevehicle _x" foreach [bob,sid]

so you will end up with a variable dist which is the distance you are after.

For the distance between a position and an object/unit, you will only need to create one logic unit ;)

Bremmer

  • Guest
Re:Distance from position
« Reply #6 on: 07 Oct 2002, 01:26:55 »
If you dont want to use game logics then just use pythagoras theory to work out the distance - you can find the x, y and z distances between the position and object you are interested in easily enough - the straight line distance is simply the square root of the sum of the squares of these three.

eg

_x = _pos select 0 - getpos player select 0
_y = _pos select 1 - getpos player select 1
_z = _pos select 2 - getpos player select 2
_distance = (_x^2 + _y^2 + _z^2)^0.5

 :)

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:Distance from position
« Reply #7 on: 07 Oct 2002, 01:29:10 »
LCD - i can't really imagine, what you wanna do in your
mission, but i can try to understand. Everyday i learn some
new things, so why shouldn't i, however;

You need that, to remember positions of deleted units.
So why don't you create a gamelogic at this position, before
deleting the unit. Or deleting the gamelogic, if creating a
unit.

Or, if i'm totally wrong now and you mean:

you delete a unit, let's say 5 meters north of the player, and
you want to create this unit later again 5 meters north of
the player, regardeless to where the player is now,

then there would be a way to:

example:

acoor = (getpos unit select 0) - (getpos player select 0);
bcoor = (getpos unit select 1) - (getpos player select 1)

:note - don't take the syntax to serious now, because i'm
not sure, if the "()" are placed correctly. You'll find out, or
already know it.  ;)

then when you need to create it again, you can use

createunit ...blablabla [(getpos player select 0) + accor,(getpos player select 1) + bcoor]

hope, there's something for yer help here

:edit - huh - again i've learned something new,
i need to type faster  ;D

~S~ CD
« Last Edit: 07 Oct 2002, 01:32:27 by Chris Death »
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

Bremmer

  • Guest
Re:Distance from position
« Reply #8 on: 07 Oct 2002, 01:34:51 »
 ;D

 :-*

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:Distance from position
« Reply #9 on: 07 Oct 2002, 02:01:45 »
@ chris - yeah i know dat  ;)  ;D


but im goin 2 use Bremmers idea  ;D but without da high part  ;D

wat im trin 2 do - is a creating/deleting vehicles script dat wil work like dat

wen daplayer enters 500 M around da place da patrol should be created - wen da player is goin 2 distance more dan 500 m from da patrol it wil disappear nd wen da player enter da area 500 M aroun were da patrol guys each 1 of em wil b created exactly in da plce he was b4  ;D but 4 dis i need 2 know wen da player is in distance from da place dey were widout creatin anoder unit - cuz wen i create anoder unit it remembers its skill, rank nd everythin else even if i dont define em - so it wil take place in my mission.sqm

i think dats all  ;D

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta