GetScreenFromWorldPosition: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
m (Needs example)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Client function}}
{{Client function}}
{{Needs_Example}}
This function gets the screen position of a point in the world. This is useful for attaching 2D gui elements to parts of the world (e.g. players) or detecting if a point is on the screen (though it does not check if it is actually visible, you should use [[processLineOfSight]] for that).
This function gets the screen position of a point in the world. This is useful for attaching 2D gui elements to parts of the world (e.g. players) or detecting if a point is on the screen (though it does not check if it is actually visible, you should use [[processLineOfSight]] for that).



Revision as of 19:04, 7 January 2014

Accessories-text-editor.png Script Example Missing Function GetScreenFromWorldPosition needs a script example, help out by writing one.

Before submitting check out Editing Guidelines Script Examples.

This function gets the screen position of a point in the world. This is useful for attaching 2D gui elements to parts of the world (e.g. players) or detecting if a point is on the screen (though it does not check if it is actually visible, you should use processLineOfSight for that).

Syntax

float float float getScreenFromWorldPosition ( float x, float y, float z, [ float edgeTolerance=0, bool relative=true ] )

Required Arguments

  • x: A float value indicating the x position in the world.
  • y: A float value indicating the y position in the world.
  • z: A float value indicating the z position in the world.

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.

  • edgeTolerance: A float value indicating the distance the position can be off screen before the function returns false.
  • relative: A boolean value that indicates if edgeTolerance is in pixels [false], or relative to the screen size [true].

Returns

Returns two x, y floats indicating the screen position and float distance between screen and given position if successful, false otherwise.

See Also