This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
4rpl:commands:getterrainlos [2021/01/08 16:01] – external edit 127.0.0.1 | 4rpl:commands:getterrainlos [2025/02/14 14:57] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 3: | Line 3: | ||
====== GetTerrainLOS ====== | ====== GetTerrainLOS ====== | ||
- | GetTerrainLOS(< | + | GetTerrainLOS(< |
===== Description ===== | ===== Description ===== | ||
- | Checks a line running from start to end and returns the terrain cell (if any) that the line first intersects. | + | Checks a line running from startPos |
- | The ' | + | This routine is useful for checking the exact terrain |
- | This routine is useful for checking the exact terrain | + | |
- | this routine can check if there is any terrain in the way. | + | -The ' |
- | The return value is the vector position in 3d space (floats) of the location where the collision took place. | + | -Returns |
+ | |||
+ | -CheckLastCell is a Boolean that will have the API extend its calculations past the endPos until it exits the cell the end position is within or a hit is encountered. A cell is a 1x1 square and any location within this square is within that cell (no matter the Y position). For reference, the center location of cell 10,15 is (10.5, | ||
+ | Example positions in cell 10,15: (10.000001, | ||
+ | Please note the bounds. An X position of 15.00000 is NOT within ANY cell located at (15,Z). 15.00000 is located within cell (14,Z) instead.)). Be mindful with this when there is a very large difference in Y-axis / " | ||
+ | |||
+ | :NOTE:\\ | ||
+ | Void (height of 0) acts as proper terrain (even outside the map). Should you use this API and it calculates a line that crosses through void terrain, it will detect the hit as expected (like (-50 0 -10)). | ||
+ | |||
+ | : | ||
+ | This API becomes unreliable when startPos and endPos | ||
+ | |||
+ | :NOTE:\\ | ||
+ | This API has its limits. It can not detect a hit at extreme angles(([Tested] Such as from (-852 500 30) to (171 3 32). End position is behind a wall and a hit is detected should the starting X pos be greater than -851 but fails otherwise (no other changes than starting X).)). | ||
===== Examples ===== | ===== Examples ===== |