User Tools

Site Tools


4rpl:commands:getunitposition

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
4rpl:commands:getunitposition [2021/01/24 14:53] – added get/set tabs Sanian4rpl:commands:getunitposition [2022/06/21 10:18] – [Examples] workaround for no return value Karsten75
Line 13: Line 13:
 Get the 3D position of a unit.  A vector is returned.  The X and Z positions are where on the map the unit is, and the Y coordinate Get the 3D position of a unit.  A vector is returned.  The X and Z positions are where on the map the unit is, and the Y coordinate
 is the height, or elevation, of the unit. is the height, or elevation, of the unit.
 +
 +Note: If this call is attempted on an non-existing unit, nothing will be put on the stack. 
  
 ===== Examples ===== ===== Examples =====
Line 20: Line 22:
 <=[[4rpl:start| Index]] <=[[4rpl:start| Index]]
  
 +
 +A "safe" method to use this function and to handle the lack of a return value on non-existent units  Are as follows:
 +
 +<code 4rpl>
 + Trace (@UnitPos(7) )
 +
 +:unitPos
 + StackSize ->stackSize   # be careful that this variable is not used in other code. 
 + GetUnitPosition
 + If (Stacksize <-stackSize EQ)
 + Return
 + else
 + V3(-1 -1 -1)
 + endif
 +</code>
4rpl/commands/getunitposition.txt · Last modified: 2023/01/19 09:28 by Karsten75