Gameplay::getGroundZFor3dCoord: Difference between revisions

From RAGE Multiplayer Wiki
No edit summary
(expanded description)
Line 1: Line 1:
Gets the ground elevation at the specified position. Note that if the specified position is below ground level, the function will output zero!<br><br>x: Position on the X-axis to get ground elevation at.<br>y: Position on the Y-axis to get ground elevation at.<br>z: Position on the Z-axis to get ground elevation at.<br>groundZ: The ground elevation at the specified position.<br>unk: Nearly always false, very rarely true in the scripts.
Returns the first surface ''beneath'' the specified elevation (at the given location).<br>
This can be a roof, an elevated road, or the ground.<br>
(If no surface can be found beneath, then the returned boolean will be false, and the float will contain 0.)<br>
For water positions the sea floor will be returned (negative value).
 
For the function to work reliably, the position tested should have been streamed already (i.e. close to the player); otherwise it might return 0.
 
==Syntax==
==Syntax==
<syntaxhighlight lang="javascript">mp.game.gameplay.getGroundZFor3dCoord(x, y, z, groundZ, unk);</syntaxhighlight>
<syntaxhighlight lang="javascript">mp.game.gameplay.getGroundZFor3dCoord(x, y, z, groundZ, unk);</syntaxhighlight>
=== Required Arguments ===
=== Required Arguments ===
*'''x:''' float
*'''x:''' float - X-coordinate of location to test
*'''y:''' float
*'''y:''' float - Y-coordinate of location to test
*'''z:''' float
*'''z:''' float - Z-coordinate, beneath which to test
*'''groundZ:''' float
*'''unk:''' boolean - unknown (normally 0)
*'''unk:''' Boolean
===Return value===
===Return value===
*'''float'''
*'''found:''' Boolean - true if surface is found, false if not
*'''groundZ:''' float - Elevation of surface found
==Example==
==Example==
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
// todo
local chk,groundZ = GetGroundZFor_3dCoord(playerPos.x,playerPos.y,playerPos.z+1,0)
</syntaxhighlight>
</syntaxhighlight>
==See also==
==See also==

Revision as of 21:38, 14 May 2019

Returns the first surface beneath the specified elevation (at the given location).
This can be a roof, an elevated road, or the ground.
(If no surface can be found beneath, then the returned boolean will be false, and the float will contain 0.)
For water positions the sea floor will be returned (negative value).

For the function to work reliably, the position tested should have been streamed already (i.e. close to the player); otherwise it might return 0.

Syntax

mp.game.gameplay.getGroundZFor3dCoord(x, y, z, groundZ, unk);

Required Arguments

  • x: float - X-coordinate of location to test
  • y: float - Y-coordinate of location to test
  • z: float - Z-coordinate, beneath which to test
  • unk: boolean - unknown (normally 0)

Return value

  • found: Boolean - true if surface is found, false if not
  • groundZ: float - Elevation of surface found

Example

local chk,groundZ = GetGroundZFor_3dCoord(playerPos.x,playerPos.y,playerPos.z+1,0)

See also

Template:Gameplay s function c