User Tools

Site Tools


4rpl:commands:getterrainlos

This is an old revision of the document!


Index

GetTerrainLOS

GetTerrainLOS(<-start <-end <-checkLastCell) ->hit

Description

Checks a line running from start to end and returns the terrain cell (if any) that the line first intersects.
This routine is useful for checking the exact terrain line of sight. If a unit wants to fire from any location in 3d space to any location in 3d space, this routine can check if there is any terrain in the way and where.

-The 'start', 'end' and 'hit' vars are all vectors.

-Checking the last cell is a Boolean that will check all cells from start to end. This is potentially useful as unit positions are located just above terrain. This parameter is a good way to reduce sensitivity when having an end position being from GetUnitPosition. (If this is wrong, feel free to update this).

-The return value is the vector position in 3d space (floats) of the location where the collision took place. If there is no collision, then the returned hit locations are negative. Please keep this in mind if wanting to place this API within an if clause. You will most likely want to run this API outside of the if clause and check if one of the vectors returns -1 instead.

:NOTE:
This API has a more applicable LOS calculation than the LOS parameter in GetUnits (at least in practice). If you are making a custom unit which depends on LOS calculations within GetUnits and it consistently fails for what ever reason to have a clear LOS in practice (such as projectiles constantly hitting into terrain), this is an EXCELENT backup to double check.

Examples

V3(0 2 0) ->start
V3(20 2 0) ->end
GetTerrainLOS(<-start <-end) ->hit

Index

4rpl/commands/getterrainlos.1661208637.txt.gz · Last modified: 2022/08/22 18:50 by Vertu