Gameplay::getGroundZFor3dCoord: Difference between revisions

From RAGE Multiplayer Wiki
(yay)
 
(updated 'see also')
 
(7 intermediate revisions by 6 users not shown)
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 0, very rarely 1 in the scripts.
{{ClientsideJsFunction}}
{{JSContainer|
 
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.
 
== Required Params ==
*'''x:''' {{RageType|float}} - X-coordinate of location to test
*'''y:''' {{RageType|float}} - Y-coordinate of location to test
*'''z:''' {{RageType|float}} - Z-coordinate, beneath which to test
*'''waterAsGround:''' {{RageType|Boolean}}
*'''waterLevelCheck:''' {{RageType|boolean}}
 
 
==Syntax==
==Syntax==
<syntaxhighlight lang="javascript">gameplay.getGroundZFor3dCoord(x, y, z, groundZ, unk);</syntaxhighlight>
<syntaxhighlight lang="javascript">
=== Required Arguments ===
mp.game.gameplay.getGroundZFor3dCoord(x, y, z, waterAsGround, waterLevelCheck);
*'''x:''' float
</syntaxhighlight>
*'''y:''' float
 
*'''z:''' float
*'''groundZ:''' float
*'''unk:''' Boolean
===Return value===
*'''float'''
==Example==
==Example==
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
todo
const {position} = mp.players.local;
const getGroundZ = mp.game.gameplay.getGroundZFor3dCoord(position.x, position.y, position.z, 0.0, false);
mp.markers.new(1, new mp.Vector3(position.x, position.y, getGroundZ), 1.5, { color: [0, 255, 0, 100], visible: true });
</syntaxhighlight>
</syntaxhighlight>
}}
==See also==
==See also==
{{Gameplay_function_c}}
{{Gameplay_definition_c}}
[[Category:Clientside API]]
[[Category:Clientside API]]
[[Category:TODO: Example]]

Latest revision as of 12:10, 29 April 2024

Client-Side
Function

 JavaScript



JavaScript Syntax


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.

Required Params

  • x: float - X-coordinate of location to test
  • y: float - Y-coordinate of location to test
  • z: float - Z-coordinate, beneath which to test
  • waterAsGround: Boolean
  • waterLevelCheck: boolean


Syntax

mp.game.gameplay.getGroundZFor3dCoord(x, y, z, waterAsGround, waterLevelCheck);

Example

const {position} = mp.players.local;
const getGroundZ = mp.game.gameplay.getGroundZFor3dCoord(position.x, position.y, position.z, 0.0, false);
mp.markers.new(1, new mp.Vector3(position.x, position.y, getGroundZ), 1.5, { color: [0, 255, 0, 100], visible: true });


See also