GetWorldFromScreenPosition: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Client function}} | {{Client function}} | ||
This function allows you to retrieve the world position corresponding to the 2D position on the screen. | This function allows you to retrieve the world position corresponding to the 2D position on the screen, at a certain depth. | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
float float float getWorldFromScreenPosition ( float x, float y, float | float, float, float getWorldFromScreenPosition ( float x, float y, float depth ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
===Required Arguments=== | ===Required Arguments=== | ||
*'''x:''' A float value | *'''x:''' A float value indicating the x position on the screen, in pixels. | ||
*'''y:''' A float value | *'''y:''' A float value indicating the y position on the screen, in pixels. | ||
*''' | *'''depth:''' A float value indicating the distance from the camera of the point whose coordinates we are retrieving, in units. | ||
===Returns=== | ===Returns=== | ||
Returns three | Returns three ''x'', ''y'', ''z'' [[float]]s indicating the world position if successful, ''false'' otherwise. | ||
==Example== | ==Example== | ||
This example binds the local player's "'''i'''" key to a function that creates an explosion in the middle of the screen. | This example binds the local player's "'''i'''" key to a function that creates an explosion in the middle of the screen. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function explosion ( | function explosion () | ||
local x, y, z = getWorldFromScreenPosition ( 0.5, 0.5, | local x, y, z = getWorldFromScreenPosition ( 0.5, 0.5, 10 ) | ||
createExplosion ( x, y, z, 11 ) | createExplosion ( x, y, z, 11 ) | ||
end | end | ||
bindKey ( "i", "down | bindKey ( "i", "down", explosion ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Client_world_functions}} | {{Client_world_functions}} |
Revision as of 18:39, 12 November 2007
This function allows you to retrieve the world position corresponding to the 2D position on the screen, at a certain depth.
Syntax
float, float, float getWorldFromScreenPosition ( float x, float y, float depth )
Required Arguments
- x: A float value indicating the x position on the screen, in pixels.
- y: A float value indicating the y position on the screen, in pixels.
- depth: A float value indicating the distance from the camera of the point whose coordinates we are retrieving, in units.
Returns
Returns three x, y, z floats indicating the world position if successful, false otherwise.
Example
This example binds the local player's "i" key to a function that creates an explosion in the middle of the screen.
function explosion () local x, y, z = getWorldFromScreenPosition ( 0.5, 0.5, 10 ) createExplosion ( x, y, z, 11 ) end bindKey ( "i", "down", explosion )
See Also
- areTrafficLightsLocked
- createSWATRope
- getAircraftMaxHeight
- getAircraftMaxVelocity
- getBirdsEnabled
- getCloudsEnabled
- getCoronaReflectionsEnabled
- getFarClipDistance
- getFogDistance
- getGameSpeed
- getGarageBoundingBox
- getGaragePosition
- getGarageSize
- getGravity
- getGroundPosition
- getHeatHaze
- getInteriorFurnitureEnabled
- getInteriorSoundsEnabled
- getJetpackMaxHeight
- getMinuteDuration
- getMoonSize
- getNearClipDistance
- getOcclusionsEnabled
- getPedsLODDistance
- getPlayerBlurLevel
- getRainLevel
- getRoofPosition
- getScreenFromWorldPosition
- getSunColor
- getSunSize
- getTime
- getTrafficLightState
- getVehiclesLODDistance
- getWeather
- getWindVelocity
- getWorldFromScreenPosition
- getZoneName
- isAmbientSoundEnabled
- isGarageOpen
- isLineOfSightClear
- isWorldSoundEnabled
- isWorldSpecialPropertyEnabled
- processLineOfSight
- removeWorldModel
- resetAmbientSounds
- resetBlurLevel
- resetColorFilter
- resetCoronaReflectionsEnabled
- resetFarClipDistance
- resetFogDistance
- resetHeatHaze
- resetMoonSize
- resetNearClipDistance
- resetPedsLODDistance
- resetRainLevel
- resetSkyGradient
- resetSunColor
- resetSunSize
- resetVehiclesLODDistance
- resetWindVelocity
- resetWorldSounds
- restoreAllWorldModels
- restoreWorldModel
- setAircraftMaxHeight
- setAircraftMaxVelocity
- setAmbientSoundEnabled
- setBirdsEnabled
- setCloudsEnabled
- setColorFilter
- setCoronaReflectionsEnabled
- setFarClipDistance
- setFogDistance
- setGameSpeed
- setGarageOpen
- setGravity
- setHeatHaze
- setInteriorFurnitureEnabled
- setInteriorSoundsEnabled
- setJetpackMaxHeight
- setMinuteDuration
- setMoonSize
- setNearClipDistance
- setOcclusionsEnabled
- setPedsLODDistance
- setPlayerBlurLevel
- setRainLevel
- setSkyGradient
- setSunColor
- setSunSize
- setTime
- setTrafficLightsLocked
- setTrafficLightState
- setVehiclesLODDistance
- setWeather
- setWeatherBlended
- setWindVelocity
- setWorldSoundEnabled
- setWorldSpecialPropertyEnabled
- testLineAgainstWater