ProcessLineOfSight: Difference between revisions
mNo edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
{{Needs_Checking|The syntax starts with bool float float float element float float float int int int? Very confusing. | |||
Explain ignoreSomeObjectsForCamera and ignoredElement with examples? | |||
--[[User:Ransom|Ransom]] 07:18, 3 February 2011 (UTC)}} | |||
{{Client function}} | {{Client function}} | ||
__NOTOC__ | __NOTOC__ |
Revision as of 07:18, 3 February 2011
This article needs checking. | |
Reason(s): The syntax starts with bool float float float element float float float int int int? Very confusing. Explain ignoreSomeObjectsForCamera and ignoredElement with examples? --Ransom 07:18, 3 February 2011 (UTC) |
This function casts a ray between two points in the world, and tells you information about the point that was hit, if any. The two positions must be within the local player's draw distance as the collision data is not loaded outside this area, and the call will just fail as if the ray didn't hit.
This function is relatively expensive to call, so over use of this in scripts may have a detrimental effect on performance.
This function is useful for checking for collisions and for editor-style scripts. If you wish to find what element is positioned at a particular point on the screen, use this function combined with getWorldFromScreenPosition. If you wish to just know if something is hit, and don't care about what or where was hit, use isLineOfSightClear.
Syntax
bool float float float element float float float int int int processLineOfSight ( float startX, float startY, float startZ, float endX, float endY, float endZ, [ bool checkBuildings = true, bool checkVehicles = true, bool checkPlayers = true, bool checkObjects = true, bool checkDummies = true, bool seeThroughStuff = false, bool ignoreSomeObjectsForCamera = false, bool shootThroughStuff = false, element ignoredElement = nil ] )
Required Arguments
- startX: The start x position
- startY: The start y position
- startZ: The start z position
- endX: The end x position
- endY: The end y position
- endZ: The end z position
Optional Arguments
NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.
- checkBuildings: Allow the line of sight to be blocked by GTA's internally placed buildings, i.e. the world map.
- checkVehicles: Allow the line of sight to be blocked by vehicles.
- checkPlayers: Allow the line of sight to be blocked by players.
- checkObjects: Allow the line of sight to be blocked by objects.
- checkDummies: Allow the line of sight to be blocked by GTA's internal dummies. These are not used in the current MTA version so this argument can be set to false.
- seeThroughStuff: Allow the line of sight to be blocked by translucent game objects, e.g. glass.
- ignoreSomeObjectsForCamera: Allow the line of sight to be blocked by certain objects.
- shootThroughStuff: Allow the line of sight to be blocked by things that can be shot through
- ignoredElement: Allow the line of sight to pass through a certain specified element.
Returns
- hit: true if there is a collision, false otherwise
The other values are only filled if there is a collision, they contain nil otherwise
- hitX, hitY, hitZ: collision position
- hitElement: the MTA element hit if any, nil otherwise
- normalX, normalY, normalZ: the normal of the surface hit
- material: an integer representing the GTASA material ID of the surface hit when applicable (world, objects)
- lighting: an integer between 0 (fully dark) and 255 (bright) representing the lighting intensity of the surface hit. This intensity is related to the lighting intensity the ped gets when standing on this surface (more than 100 in general, less than 20 in dark areas, and 0 to 1 in stealth parts of Madd Dogg's mansion)
- piece: an integer representing the part of the element hit if hitElement is a vehicle or a ped/player, 0 otherwise.
- For a ped/player, piece represents the body part hit:
- 3: Torso
- 4: Ass
- 5: Left Arm
- 6: Right Arm
- 7: Left Leg
- 8: Right Leg
- 9: Head
- For vehicles, piece represents the vehicle part hit:
- 0: Frame
- 2: Trunk
- 3: Hood
- 4: Rear
- 5: Front left door
- 6: Front right door
- 7: Rear left door
- 8: Rear right door
- 13: Front Left tyre
- 14: Front Right tyre
- 15: Back Left tyre
- 16: Back Right tyre
(Other potential IDs haven't been documented yet and might depend on vehicle model)
Example
This example shows how you can tell what position and element the camera is looking at, up to 50 units away.
local w, h = guiGetScreenSize () local tx, ty, tz = getWorldFromScreenPosition ( w/2, h/2, 50 ) local px, py, pz = getCameraMatrix() hit, x, y, z, elementHit = processLineOfSight ( px, py, pz, tx, ty, tz ) if hit then outputChatBox ( "Looking at " .. x .. ", " .. y .. ", " .. z ) if elementHit then outputChatBox ( "Hit element " .. getElementType(elementHit) ) 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