BIS fnc setPitchBank: Difference between revisions
Jump to navigation
Jump to search
m (see also) |
Lou Montana (talk | contribs) (Page filling) |
||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
{{Function|Comments= | |||
{{Function|= | |||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ | ||
| arma2 | | | arma2 |Game name= | ||
|1.00| | |1.00|Game version= | ||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ | ||
| < | | Rotate an object, giving it the specified pitch and bank, in degrees.<br /> | ||
/ | '''Pitch''' is 0 when the object is level; 90 when pointing straight up; and -90 when pointing straight down.<br /> | ||
'''Bank''' is 0 when level; 90 when the object is rolled to the right, -90 when rolled to the left, and 180 when rolled upside down.<br /> | |||
Note that the object's '''yaw''' can be set with the [[setDir]] command, which should be issued before using this function, if required.<br /> | |||
The pitch/bank can be leveled out (set to 0) by using the [[setDir]] command. |Description= | |||
____________________________________________________________________________________________ | |||
| [object, pitch, bank] call [[BIS_fnc_setPitchBank]] |Syntax= | |||
|p1= object: [[Object]] |Parameter 1= | |||
|p2= pitch: [[Number]] |Parameter 2= | |||
|p3= Number: [[Number]] |Parameter 3= | |||
| [[Nothing]] |Return value= | |||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ | ||
| < | |x1= <code><nowiki>[</nowiki>[[player]], 45, -45] [[call]] [[BIS_fnc_setPitchBank]];</code> |Example 1= | ||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ | ||
| | | [[BIS_fnc_getPitchBank]], [[vectorDir]], [[vectorUp]], [[setVectorDirAndUp]] |See also= | ||
}} | }} | ||
Line 54: | Line 34: | ||
<dl class="command_description"> | <dl class="command_description"> | ||
<!-- Note Section BEGIN --> | <!-- Note Section BEGIN --> | ||
<dd class="notedate">Posted on Aug 4, 2014 – 13:35 | |||
<dt class="note">[[User:ffur2007slx2_5|ffur2007slx2_5]]<dd class="note"> | |||
(A3 1.24) [[attachTo]] limits [[BIS_fnc_setPitchBank]], here’s an alternative function to break that limitation (code originated from [[bapedibupa]]): | |||
<code> | |||
_obj [[attachTo]] [_logic,[0,0,2]]; | |||
[_obj,[120,-78,37]] [[call]] fnc_SetPitchBankYaw; // pitch: 120, bank: -78, yaw: 37</code> | |||
<code> | |||
fnc_SetPitchBankYaw = { | |||
[[private]] ["_object","_rotations","_aroundX","_aroundY","_aroundZ","_dirX","_dirY","_dirZ","_upX","_upY","_upZ","_dir","_up","_dirXTemp", | |||
"_upXTemp"]; | |||
_object = _this [[select]] 0; | |||
_rotations = _this [[select]] 1; | |||
_aroundX = _rotations [[select]] 0; | |||
_aroundY = _rotations [[select]] 1; | |||
_aroundZ = (360 - (_rotations [[select]] 2)) - 360; | |||
_dirX = 0; | |||
_dirY = 1; | |||
_dirZ = 0; | |||
_upX = 0; | |||
_upY = 0; | |||
_upZ = 1; | |||
[[if]] (_aroundX != 0) [[then]] { | |||
_dirY = [[cos]] _aroundX; | |||
_dirZ = [[sin]] _aroundX; | |||
_upY = -[[sin]] _aroundX; | |||
_upZ = [[cos]] _aroundX; | |||
}; | |||
[[if]] (_aroundY != 0) [[then]] { | |||
_dirX = _dirZ * [[sin]] _aroundY; | |||
_dirZ = _dirZ * [[cos]] _aroundY; | |||
_upX = _upZ * [[sin]] _aroundY; | |||
_upZ = _upZ * [[cos]] _aroundY; | |||
}; | |||
[[if]] (_aroundZ != 0) [[then]] { | |||
_dirXTemp = _dirX; | |||
_dirX = (_dirXTemp* [[cos]] _aroundZ) - (_dirY * [[sin]] _aroundZ); | |||
_dirY = (_dirY * [[cos]] _aroundZ) + (_dirXTemp * [[sin]] _aroundZ); | |||
_upXTemp = _upX; | |||
_upX = (_upXTemp * [[cos]] _aroundZ) - (_upY * [[sin]] _aroundZ); | |||
_upY = (_upY * [[cos]] _aroundZ) + (_upXTemp * [[sin]] _aroundZ); | |||
}; | |||
_dir = [_dirX,_dirY,_dirZ]; | |||
_up = [_upX,_upY,_upZ]; | |||
_object [[setVectorDirAndUp]] [_dir,_up]; | |||
}; | |||
</code> | |||
<!-- Note Section END --> | <!-- Note Section END --> | ||
</dl> | </dl> | ||
<h3 style="display:none">Bottom Section</h3> | <h3 style="display:none">Bottom Section</h3> | ||
[[Category:Functions|{{uc:setPitchBank}}]] | |||
[[Category:Function Group: Objects|{{uc:setPitchBank}}]] | [[Category:Function Group: Objects|{{uc:setPitchBank}}]] | ||
[[Category:{{Name|arma2}}: Functions|{{uc:setPitchBank}}]] | [[Category:{{Name|arma2}}: Functions|{{uc:setPitchBank}}]] | ||
[[Category:{{Name|arma2oa}}: Functions|{{uc:setPitchBank}}]] | [[Category:{{Name|arma2oa}}: Functions|{{uc:setPitchBank}}]] | ||
[[Category:{{Name|tkoh}}: Functions|{{uc:setPitchBank}}]] | [[Category:{{Name|tkoh}}: Functions|{{uc:setPitchBank}}]] | ||
[[Category:{{Name|arma3}}: Functions|{{uc:setPitchBank}}]] | [[Category:{{Name|arma3}}: Functions|{{uc:setPitchBank}}]] |
Revision as of 22:55, 30 May 2018
Description
- Description:
- Rotate an object, giving it the specified pitch and bank, in degrees.
Pitch is 0 when the object is level; 90 when pointing straight up; and -90 when pointing straight down.
Bank is 0 when level; 90 when the object is rolled to the right, -90 when rolled to the left, and 180 when rolled upside down.
Note that the object's yaw can be set with the setDir command, which should be issued before using this function, if required.
The pitch/bank can be leveled out (set to 0) by using the setDir command. - Execution:
- call
- Groups:
- Uncategorised
Syntax
- Syntax:
- [object, pitch, bank] call BIS_fnc_setPitchBank
- Parameters:
- object: Object
- pitch: Number
- Number: Number
- Return Value:
- Nothing
Examples
- Example 1:
[player, 45, -45] call BIS_fnc_setPitchBank;
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
Notes
- Posted on Aug 4, 2014 – 13:35
- ffur2007slx2_5
-
(A3 1.24) attachTo limits BIS_fnc_setPitchBank, here’s an alternative function to break that limitation (code originated from bapedibupa):
_obj attachTo [_logic,[0,0,2]]; [_obj,[120,-78,37]] call fnc_SetPitchBankYaw; // pitch: 120, bank: -78, yaw: 37
fnc_SetPitchBankYaw = { private ["_object","_rotations","_aroundX","_aroundY","_aroundZ","_dirX","_dirY","_dirZ","_upX","_upY","_upZ","_dir","_up","_dirXTemp", "_upXTemp"]; _object = _this select 0; _rotations = _this select 1; _aroundX = _rotations select 0; _aroundY = _rotations select 1; _aroundZ = (360 - (_rotations select 2)) - 360; _dirX = 0; _dirY = 1; _dirZ = 0; _upX = 0; _upY = 0; _upZ = 1; if (_aroundX != 0) then { _dirY = cos _aroundX; _dirZ = sin _aroundX; _upY = -sin _aroundX; _upZ = cos _aroundX; }; if (_aroundY != 0) then { _dirX = _dirZ * sin _aroundY; _dirZ = _dirZ * cos _aroundY; _upX = _upZ * sin _aroundY; _upZ = _upZ * cos _aroundY; }; if (_aroundZ != 0) then { _dirXTemp = _dirX; _dirX = (_dirXTemp* cos _aroundZ) - (_dirY * sin _aroundZ); _dirY = (_dirY * cos _aroundZ) + (_dirXTemp * sin _aroundZ); _upXTemp = _upX; _upX = (_upXTemp * cos _aroundZ) - (_upY * sin _aroundZ); _upY = (_upY * cos _aroundZ) + (_upXTemp * sin _aroundZ); }; _dir = [_dirX,_dirY,_dirZ]; _up = [_upX,_upY,_upZ]; _object setVectorDirAndUp [_dir,_up]; };