Squirrel/Client/Functions/Misc/WorldPosToScreen
From Liberty Unleashed Wiki
(Difference between revisions)
(Created page with "== Syntax == <code>VectorScreen WorldPosToScreen( Vector Position )</code>") |
(→Syntax) |
||
Line 2: | Line 2: | ||
<code>VectorScreen WorldPosToScreen( Vector Position )</code> | <code>VectorScreen WorldPosToScreen( Vector Position )</code> | ||
+ | |||
+ | == Arguments == | ||
+ | |||
+ | * '''Vector''' - A 3D vector value from a world position. | ||
+ | |||
+ | == Example == | ||
+ | |||
+ | This code will get a position on the screen (for GUI) from a 3D position in the game. | ||
+ | |||
+ | <code lang="squirrel"> | ||
+ | function onClientCommand(cmd, text) | ||
+ | { | ||
+ | if(cmd == "myscreenpos") | ||
+ | { | ||
+ | local LocalPlayer = FindLocalPlayer( ); | ||
+ | local myScreenPos = WorldPosToScreen ( LocalPlayer.Pos ); | ||
+ | Message ( "The screen position is " + myScreenPos.x + ", " + myScreenPos.y ); | ||
+ | } | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | === Notes === | ||
+ | |||
+ | The event [[Squirrel/Client/Events/Player/onClientCommand|onClientCommand]] and function [[Squirrel/Client/Functions/Players/FindLocalPlayer|FindLocalPlayer]] was used in this example. More information is available on its corresponding page. |
Latest revision as of 21:10, 2 April 2017
Contents |
[edit] Syntax
VectorScreen WorldPosToScreen( Vector Position )
[edit] Arguments
- Vector - A 3D vector value from a world position.
[edit] Example
This code will get a position on the screen (for GUI) from a 3D position in the game.
function onClientCommand(cmd, text) { if(cmd == "myscreenpos") { local LocalPlayer = FindLocalPlayer( ); local myScreenPos = WorldPosToScreen ( LocalPlayer.Pos ); Message ( "The screen position is " + myScreenPos.x + ", " + myScreenPos.y ); } }
[edit] Notes
The event onClientCommand and function FindLocalPlayer was used in this example. More information is available on its corresponding page.