GetGroundPosition: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
m (→Example) |
||
Line 26: | Line 26: | ||
--we'll check for ground level at the player's position, and also 500 units over him. | --we'll check for ground level at the player's position, and also 500 units over him. | ||
--if these ground levels match, it must mean there were no obstacles (such as a ceiling) over the player, | --if these ground levels match, it must mean there were no obstacles (such as a ceiling) over the player, | ||
if getGroundPosition ( px, py, pz ) == getGroundPosition ( px, py, pz + | if getGroundPosition ( px, py, pz ) == getGroundPosition ( px, py, pz + 530 ) then | ||
-- so the player is not under cover | -- so the player is not under cover | ||
return false | return false |
Revision as of 22:26, 12 October 2019
This function gets the Z level of the highest ground below a point.
It is required that the point is near enough to the local player so that it's within the area where collision data is loaded. If this is not the case, an incorrect position will be returned.
Syntax
float getGroundPosition ( float x, float y, float z )
Required Arguments
- x: A floating point number representing the X world coordinate of the point.
- y: A floating point number representing the Y world coordinate of the point.
- z: A floating point number representing the Z world coordinate of the point.
Returns
Returns a float with the highest ground-level Z coord if parameters are valid, 0 if the point you tried to test is outside the loaded world map, false otherwise.
Example
This clientside function determines if a player is under a ceiling or not.
function isPlayerUnderCover ( thePlayer ) --we get the player's position local px, py, pz = getElementPosition ( thePlayer ) --we'll check for ground level at the player's position, and also 500 units over him. --if these ground levels match, it must mean there were no obstacles (such as a ceiling) over the player, if getGroundPosition ( px, py, pz ) == getGroundPosition ( px, py, pz + 530 ) then -- so the player is not under cover return false --otherwise, there was an object over him, else -- so the player is under cover return true end end
See Also
- createSWATRope
- getBirdsEnabled
- getCoronaReflectionsEnabled
- getGarageBoundingBox
- getGaragePosition
- getGarageSize
- getGroundPosition
- getInteriorFurnitureEnabled
- getNearClipDistance
- getPedsLODDistance
- getRoofPosition
- getScreenFromWorldPosition
- getVehiclesLODDistance
- getWorldFromScreenPosition
- isAmbientSoundEnabled
- isLineOfSightClear
- isWorldSoundEnabled
- processLineOfSight
- resetAmbientSounds
- resetBlurLevel
- resetColorFilter
- resetCoronaReflectionsEnabled
- resetNearClipDistance
- resetPedsLODDistance
- resetVehiclesLODDistance
- resetWorldSounds
- setAmbientSoundEnabled
- setBirdsEnabled
- setColorFilter
- setCoronaReflectionsEnabled
- setInteriorFurnitureEnabled
- setInteriorSoundsEnabled
- setNearClipDistance
- setPedsLODDistance
- setVehiclesLODDistance
- setWorldSoundEnabled
- testLineAgainstWater
- areTrafficLightsLocked
- getAircraftMaxHeight
- getAircraftMaxVelocity
- getCloudsEnabled
- getFarClipDistance
- getFogDistance
- getGameSpeed
- getGravity
- getHeatHaze
- getInteriorSoundsEnabled
- getJetpackMaxHeight
- getMinuteDuration
- getMoonSize
- getOcclusionsEnabled
- getRainLevel
- getSunColor
- getSunSize
- getTime
- getTrafficLightState
- getWeather
- getWindVelocity
- getSkyGradient
- getPlayerBlurLevel
- getZoneName
- isGarageOpen
- removeWorldModel
- resetFarClipDistance
- resetFogDistance
- resetHeatHaze
- resetMoonSize
- resetRainLevel
- resetSkyGradient
- resetSunColor
- resetSunSize
- resetWindVelocity
- restoreAllWorldModels
- restoreWorldModel
- setAircraftMaxHeight
- setAircraftMaxVelocity
- setCloudsEnabled
- setFarClipDistance
- setFogDistance
- setGameSpeed
- setGarageOpen
- setGravity
- setHeatHaze
- setInteriorSoundsEnabled
- setMinuteDuration
- setMoonSize
- setOcclusionsEnabled
- setRainLevel
- setSkyGradient
- setSunColor
- setSunSize
- setTime
- setTrafficLightState
- setTrafficLightsLocked
- setWeather
- setWeatherBlended
- setWindVelocity
- setJetpackMaxHeight
- setPlayerBlurLevel