eyeDirection: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - " <nowiki>[</nowiki>" to " [<nowiki/>")
m (Some wiki formatting)
 
(82 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Command|Comments=
{{RV|type=command
____________________________________________________________________________________________


| arma3 |Game name=
|game1= arma3
|0.50|Game version=
|version1= 0.50
|arg= global|Multiplayer Arguments=
|arg= global
____________________________________________________________________________________________


| Returns the direction object is watching (eyes, or a vehicle primary observer).  |DESCRIPTION=
|gr1= Object Manipulation
____________________________________________________________________________________________


| '''eyeDirection''' unit |SYNTAX=
|descr= Returns the direction object is watching (eyes, or a vehicle's primary observer).


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


| [[Array]] - 3D Vector|RETURNVALUE=
|p1= unit: [[Object]]


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


|x1= <code>can = "Land_Can_V3_F" [[createVehicle]] [[position]] [[player]];  
|x1= Keep a can in front of the player's ''face'':
[[onEachFrame]] {
<sqf>
    can [[setPosASL]] [
Can = "Land_Can_V3_F" createVehicle getPosATL player;
        ([[eyePos]] [[player]] [[select]] 0) + ([[eyeDirection]] [[player]] [[select]] 0),
onEachFrame {
        ([[eyePos]] [[player]] [[select]] 1) + ([[eyeDirection]] [[player]] [[select]] 1),
_eyePos = eyePos player;
        ([[eyePos]] [[player]] [[select]] 2) + ([[eyeDirection]] [[player]] [[select]] 2)
_eyeDir = eyeDirection player;
    ]
Can setPosASL [
}
_eyePos select 0 + (_eyeDir select 0),
</code>|EXAMPLE1=
_eyePos select 1 + (_eyeDir select 1),
_eyePos select 2 + (_eyeDir select 2)
]
};
</sqf>


|x2= Draw AI eye direction (green) and weapon direction (red) in 3D: <code>bob = [[createGroup]] [[east]] [[createUnit]] ["O_Soldier_F", [0,0,0], [], 0, "NONE"];
|x2= Draw AI eye direction (green) and weapon direction (red) in 3D:
bob [[setVehiclePosition]] [<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]];
_endW = (_beg [[vectorAdd]] (bob [[weaponDirection]] [[currentWeapon]] bob [[vectorMultiply]] 100));
[[drawLine3D]] [_beg, _endW, [1,0,0,1]];
};</code> |EXAMPLE2=
____________________________________________________________________________________________


| [[positionCameraToWorld]], [[weaponDirection]], [[getCameraViewDirection]], [[vectorDir]], [[vectorDirVisual]] |SEEALSO=
_endE = _beg vectorAdd (eyeDirection Bob vectorMultiply 100);
drawLine3D [_beg, _endE, [0,1,0,1]];


| |MPBEHAVIOUR=  
_endW = _beg vectorAdd (Bob weaponDirection currentWeapon Bob vectorMultiply 100);
____________________________________________________________________________________________
drawLine3D [_beg, _endW, [1,0,0,1]];
};
</sqf>
 
|seealso= [[positionCameraToWorld]] [[weaponDirection]] [[getCameraViewDirection]] [[vectorDir]] [[vectorDirVisual]]
}}
}}


<h3 style='display:none'>Notes</h3>
{{Note
<dl class='command_description'>
|user= Killzone_Kid
<!-- Note Section BEGIN -->
|timestamp= 20140526191000
 
|text= This command should have really been named ''headDirection'' instead of [[eyeDirection]] as one could mistakenly think that eyes direction of your avatar correspond to the direction of the centre of your screen.
<!-- Note Section END -->
Play with the script in {{Link|#Example 1}} to find out limitations. If you need centre of screen direction, use [[positionCameraToWorld]] instead.
</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}}}}]]
 
<!-- CONTINUE Notes -->
<dl class="command_description">
<dd class="notedate">Posted on May 26, 2014 - 19:10 (UTC)</dd>
<dt class="note">'''[[User:Killzone Kid|Killzone Kid]]'''</dt>
<dd class="note">
This command should have really been named ''headDirection'' instead of [[eyeDirection]] as one could mistakenly think that eyes direction of your avatar correspond to the direction of the centre of your screen. Play with the script in example 1 to find out limitations. If you need centre of screen direction, use [[positionCameraToWorld]] instead.
</dd>
</dl>
<!-- DISCONTINUE Notes -->

Latest revision as of 00:12, 11 November 2024

Hover & click on the images for description

Description

Description:
Returns the direction object is watching (eyes, or a vehicle's primary observer).
Groups:
Object Manipulation

Syntax

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

Examples

Example 1:
Keep a can in front of the player's face:
Can = "Land_Can_V3_F" createVehicle getPosATL player; onEachFrame { _eyePos = eyePos player; _eyeDir = eyeDirection player; Can setPosASL [ _eyePos select 0 + (_eyeDir select 0), _eyePos select 1 + (_eyeDir select 1), _eyePos select 2 + (_eyeDir select 2) ] };
Example 2:
Draw AI eye direction (green) and weapon direction (red) 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]]; };

Additional Information

See also:
positionCameraToWorld weaponDirection getCameraViewDirection 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
Killzone_Kid - c
Posted on May 26, 2014 - 19:10 (UTC)
This command should have really been named headDirection instead of eyeDirection as one could mistakenly think that eyes direction of your avatar correspond to the direction of the centre of your screen. Play with the script in Example 1 to find out limitations. If you need centre of screen direction, use positionCameraToWorld instead.