This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| 4rpl:commands:getunitposition [2021/01/08 16:01] – external edit 127.0.0.1 | 4rpl:commands:getunitposition [2025/02/14 14:57] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ~~NOTOC~~ | ~~NOTOC~~ | ||
| < | < | ||
| + | |||
| + | <WRAP tabs> | ||
| + | * [[4rpl: | ||
| + | * [[4rpl: | ||
| + | </ | ||
| ====== GetUnitPosition ====== | ====== GetUnitPosition ====== | ||
| Line 8: | Line 13: | ||
| Get the 3D position of a unit. A vector is returned. | Get the 3D position of a unit. A vector is returned. | ||
| 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. | ||
| + | In V 2.4, this behavior changes and this API will now return V3(0 0 0), similar to other APIs. | ||
| ===== Examples ===== | ===== Examples ===== | ||
| <code 4rpl> | <code 4rpl> | ||
| GetUnitPosition(< | GetUnitPosition(< | ||
| + | |||
| + | # to extract the individual values from the above vector: | ||
| + | <-pos.x -> | ||
| + | <-pos.y -> | ||
| + | <-pos.z -> | ||
| + | |||
| + | # or use the .dot syntax above to directly access the values in the vector, or | ||
| + | |||
| + | EV3(< | ||
| + | |||
| </ | </ | ||
| + | |||
| + | |||
| + | A " | ||
| + | |||
| + | <code 4rpl> | ||
| + | Trace (@UnitPos(7) ) | ||
| + | |||
| + | :unitPos | ||
| + | StackSize ->size | ||
| + | GetUnitPosition | ||
| + | If (Stacksize <-size NEQ) | ||
| + | V3(-1 -1 -1) | ||
| + | endif | ||
| + | </ | ||
| + | |||
| < | < | ||