Home   Help Search Login Register  

Author Topic: Back up  (Read 470 times)

0 Members and 1 Guest are viewing this topic.

Anci

  • Guest
Back up
« on: 24 Jun 2003, 09:11:37 »
How to make unit to move near other unit ?

unit1 move (getpos unit2)  <--- this causes unit1 move to exactly same place where unit2 is, but how can i make unit1  move let's say 50 meters away from unit2 ?

I hope u got the idea...  :)
« Last Edit: 24 Jun 2003, 12:58:53 by Anci »

Knut Erik

  • Guest
Re:Back up
« Reply #1 on: 24 Jun 2003, 12:18:37 »
Ahh.. Tricky one..

Unit1 move [(getpos unit2 select 0) + 50, getpos unit2 select 1, getpos unit2 select 2]

Does it work?

Anci

  • Guest
Re:Back up
« Reply #2 on: 24 Jun 2003, 12:44:09 »
It works ! :D

Would u explain to me a little bit how it works ?
I don't understand what's the purpose of that select-command.


Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:Back up
« Reply #3 on: 24 Jun 2003, 13:25:29 »
position object returns a 2D/3D array of the coordinates.

_pos = (getpos player)

would make: _pos =[xxx.xxxxxx,xxx.xxxxxx,xxx.xxxxxx]

x/y/z-axis coordinates

Now when refering to the whole array you can say:

object setpos (getpos player)
or:
object setpos _pos

But if you want to the value of any of the coordinates you
have to do it piece by piece for the specific element of the
array.

Let's say you want to place it 10 meters more to the left,
then you need to increase element 0 of array _pos with
the value of 10:

_newpos = [_pos select 0 + 10,_pos select 1,_pos select 2]

Now as the third element (_pos select 2) specifies the height
value, this is not really required to be used, as long as you
only want to do: 2D setpos (move object from one place to
another).

Therefore you can also say:

_newpos = [_pos select 0 + 10,_pos select 1]


P.S: don't take left/right/up/down too serious for my explanation, as i'm not sure right now if it's element 0 or
element 1, which represents the left/right axis.
Just play around a lil bit with that and you'll see.

~S~ CD

Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

Anci

  • Guest
Re:Back up
« Reply #4 on: 24 Jun 2003, 13:31:07 »
Thanks. This clarified things for me.  :)