eyeDirection: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Text replacement - " \| *(game[0-9]|version[0-9]|gr[0-9]|serverExec|mp|pr|descr|s[0-9]|p[0-9]{1,3}|r[0-9]|x1?[0-9]|seealso) *= +" to " |$1= ") |
Lou Montana (talk | contribs) m (Some wiki formatting) |
||
(58 intermediate revisions by 2 users not shown) | |||
Line 7: | Line 7: | ||
|gr1= Object Manipulation | |gr1= Object Manipulation | ||
|descr= Returns the direction object is watching (eyes, or a vehicle primary observer). | |descr= Returns the direction object is watching (eyes, or a vehicle's primary observer). | ||
|s1= | |s1= [[eyeDirection]] unit | ||
|p1= unit: [[Object]] | |p1= unit: [[Object]] | ||
|r1=[[Array]] - 3D Vector | |r1= [[Array]] - 3D Vector | ||
|x1= < | |x1= Keep a can in front of the player's ''face'': | ||
<sqf> | |||
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) | |||
] | |||
}; | |||
</sqf> | |||
|x2= Draw AI eye direction (green) and weapon direction (red) in 3D: < | |x2= Draw AI eye direction (green) and weapon direction (red) in 3D: | ||
<sqf> | |||
Bob = createGroup east createUnit ["O_Soldier_F", [0,0,0], [], 0, "NONE"]; | |||
{ | Bob setVehiclePosition [player modelToWorld [0,100,0], [], 0, "NONE"]; | ||
_beg = | 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]]; | |||
}; | |||
</sqf> | |||
|seealso= [[positionCameraToWorld]] [[weaponDirection]] [[getCameraViewDirection]] [[vectorDir]] [[vectorDirVisual]] | |||
}} | |||
{{Note | |||
|user= Killzone_Kid | |||
|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. | |||
Play with the script in {{Link|#Example 1}} to find out limitations. If you need centre of screen direction, use [[positionCameraToWorld]] instead. | |||
}} |
Latest revision as of 00:12, 11 November 2024
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:
- 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
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
- 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.