worldToScreen: Difference between revisions

From Bohemia Interactive Community
(add. ArmA2 classification)
 
(updated format for parsing)
 
(50 intermediate revisions by 10 users not shown)
Line 1: Line 1:
{{RV|type=command


[[Category:Scripting Commands ArmA2|{{uc:{{PAGENAME}}}}]]
|game1= arma2
|version1= 1.00
 
|game2= arma2oa
|version2= 1.50
 
|game3= tkoh
|version3= 1.00
 
|game4= arma3
|version4= 0.50
 
|gr1= Positions
 
|descr= Converts position in world space into screen (UI) space. If a specified position is not within the current screen view, an empty array is returned.
{{Feature | informative | [[SafeZone]]s should be considered:
* the result can be out of the [0,0]..[1,1] range
* the result can be a filled array even if the position is not displayed on screen if it would appear on a triplescreen setup
}}
 
|s1= [[worldToScreen]] position
 
|p1= position: [[Position#Position2D|Position2D]], [[Position#PositionAGL|PositionAGL]]
 
|r1= [[Array]] with [x, y] - screen position in [[SafeZone]]. Returns an empty array {{hl|[]}} if not on-screen.
* x: [[Number]]
* y: [[Number]]
 
|s2= camera [[worldToScreen]] position
|s2since= arma3 2.18
 
|p21= camera: [[Object]] - camera object
 
|p22= position: [[Position#Position2D|Position2D]], [[Position#PositionAGL|PositionAGL]]
 
|r2= [[Array]] with [x, y] - screen position in [[SafeZone]]. Returns an empty array {{hl|[]}} if not on-screen.
* x: [[Number]]
* y: [[Number]]
 
|x1= <sqf>_screenPos = worldToScreen ASLToAGL getPosASL soldier1;</sqf>
 
|x2= <sqf>_screenPos = worldToScreen (player modelToWorld [0,10,0]);</sqf>
 
|seealso= [[screenToWorld]] [[SafeZone]]
}}

Latest revision as of 20:00, 5 January 2026

Hover & click on the images for description

Description

Description:
Converts position in world space into screen (UI) space. If a specified position is not within the current screen view, an empty array is returned.
SafeZones should be considered:
  • the result can be out of the [0,0]..[1,1] range
  • the result can be a filled array even if the position is not displayed on screen if it would appear on a triplescreen setup
Groups:
Positions

Syntax

Syntax:
worldToScreen position
Parameters:
position: Position2D, PositionAGL
Return Value:
Array with [x, y] - screen position in SafeZone. Returns an empty array [] if not on-screen.

Alternative Syntax

Syntax:
camera worldToScreen position
Parameters:
camera: Object - camera object
position: Position2D, PositionAGL
Return Value:
Array with [x, y] - screen position in SafeZone. Returns an empty array [] if not on-screen.

Examples

Example 1:
_screenPos = worldToScreen ASLToAGL getPosASL soldier1;
Example 2:
_screenPos = worldToScreen (player modelToWorld [0,10,0]);

Additional Information

See also:
screenToWorld SafeZone

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord.
Only post proven facts here! Add Note