getCameraViewDirection: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(Created page with "{{Command|= Comments ____________________________________________________________________________________________ | arma3dev |= Game name |1.57|= Game version ______________...")
 
m (Text replacement - " +\[ +" to " [")
 
(64 intermediate revisions by 7 users not shown)
Line 1: Line 1:
{{Command|= Comments
{{RV|type=command
____________________________________________________________________________________________


| arma3dev |= Game name
|game1= arma3
|1.57|= Game version
|version1= 1.58
|arg= global


____________________________________________________________________________________________
|gr1= Object Manipulation


| Returns the direction unit is looking. |= Description
|descr= Returns the direction unit is looking in render time scope. While for AI the origin for the view direction vector can be taken from <sqf inline>eyePos unit</sqf>, for human player the origin should be taken from player camera position <sqf inline>positionCameraToWorld [0,0,0]</sqf>
____________________________________________________________________________________________


| '''getCameraViewDirection''' unit |= Syntax
|s1= [[getCameraViewDirection]] unit


|p1= unit: [[Object]] |= PARAMETER1
|p1= unit: [[Object]]


| [[Array]] - 3D Vector |= RETURNVALUE
|r1= [[Array]] - 3D Vector


|x1= Draw AI eye direction (green), weapon direction (red) and camera direction (blue) in 3D: <code>bob = [[createGroup]] [[east]] [[createUnit]] ["O_Soldier_F", [0,0,0], [], 0, "NONE"];
|x1= Draw AI eye direction (green), weapon direction (red) and camera direction (blue) in 3D:
bob [[setVehiclePosition]] <nowiki>[</nowiki>[[player]] [[modelToWorld]] [0,100,0], [], 0, "NONE"];
<sqf>
[[onEachFrame]]
Bob = createGroup east createUnit ["O_Soldier_F", [0,0,0], [], 0, "NONE"];
{
Bob setVehiclePosition [player modelToWorld [0,100,0], [], 0, "NONE"];
_beg = [[ASLToAGL]] [[eyePos]] bob;
onEachFrame {
_endE = (_beg [[vectorAdd]] ([[eyeDirection]] bob [[vectorMultiply]] 100));
_beg = ASLToAGL eyePos Bob;
[[drawLine3D]] [ _beg, _endE, [0,1,0,1]];
_endE = (_beg vectorAdd (eyeDirection Bob vectorMultiply 100));
_endW = (_beg [[vectorAdd]] (bob [[weaponDirection]] [[currentWeapon]] bob [[vectorMultiply]] 100));
drawLine3D [_beg, _endE, [0,1,0,1]];
[[drawLine3D]] [_beg, _endW, [1,0,0,1]];
_endW = (_beg vectorAdd (Bob weaponDirection currentWeapon Bob vectorMultiply 100));
_endV = (_beg [[vectorAdd]] ([[getCameraViewDirection]] bob [[vectorMultiply]] 100));
drawLine3D [_beg, _endW, [1,0,0,1]];
[[drawLine3D]] [_beg, _endV, [0,0,1,1]];
_endV = (_beg vectorAdd (getCameraViewDirection Bob vectorMultiply 100));
};</code>|= EXAMPLE1
drawLine3D [_beg, _endV, [0,0,1,1]];
};
</sqf>


____________________________________________________________________________________________
|seealso= [[positionCameraToWorld]] [[weaponDirection]] [[eyeDirection]] [[vectorDir]] [[vectorDirVisual]]
 
| [[positionCameraToWorld]], [[weaponDirection]], [[eyeDirection]], [[vectorDir]], [[vectorDirVisual]] |= SEEALSO
 
|  |= MPBEHAVIOUR
____________________________________________________________________________________________
}}
}}
<h3 style='display:none'>Notes</h3>
<dl class='command_description'>
<!-- Note Section BEGIN -->
<!-- Note Section END -->
</dl>
<h3 style='display:none'>Bottom Section</h3>
[[Category:Arma_3:_New_Scripting_Commands_List|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]

Latest revision as of 17:48, 8 November 2023

Hover & click on the images for description

Description

Description:
Returns the direction unit is looking in render time scope. While for AI the origin for the view direction vector can be taken from eyePos unit, for human player the origin should be taken from player camera position positionCameraToWorld [0,0,0]
Groups:
Object Manipulation

Syntax

Syntax:
getCameraViewDirection unit
Parameters:
unit: Object
Return Value:
Array - 3D Vector

Examples

Example 1:
Draw AI eye direction (green), weapon direction (red) and camera direction (blue) in 3D:
Bob = createGroup east createUnit ["O_Soldier_F", [0,0,0], [], 0, "NONE"]; Bob setVehiclePosition [player modelToWorld [0,100,0], [], 0, "NONE"]; onEachFrame { _beg = ASLToAGL eyePos Bob; _endE = (_beg vectorAdd (eyeDirection Bob vectorMultiply 100)); drawLine3D [_beg, _endE, [0,1,0,1]]; _endW = (_beg vectorAdd (Bob weaponDirection currentWeapon Bob vectorMultiply 100)); drawLine3D [_beg, _endW, [1,0,0,1]]; _endV = (_beg vectorAdd (getCameraViewDirection Bob vectorMultiply 100)); drawLine3D [_beg, _endV, [0,0,1,1]]; };

Additional Information

See also:
positionCameraToWorld weaponDirection eyeDirection vectorDir vectorDirVisual

Notes

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