DLib/functions/Util/fn_attachToRelative.sqf

46 lines
1.0 KiB
Plaintext
Raw Normal View History

2020-01-15 18:18:38 +00:00
/*
Author: Djeeberjr (code based on killzonekid)
Description:
Attaches an object realtive to its current position.
Parameter(s):
0: OBJECT - to attach
1: OBJECT - to attach to
*/
params ["_child","_parent"];
_vis = _parent worldToModelVisual [0,0,0];
_vector = [
_parent worldToModelVisual vectorDirVisual _child vectorDiff _vis,
_parent worldToModelVisual vectorUpVisual _child vectorDiff _vis
];
_child attachTo [_parent];
_child setVectorDirAndUp _vector;
/*
KK_fnc_attachToRelative = {
private ["_o","_v"];
_o = _this select 0;
_v = _this call KK_fnc_vectorDirAndUpRelative;
_o attachTo [_this select 1];
_o setVectorDirAndUp _v;
};
KK_fnc_vectorDirAndUpRelative = {
private ["_o1","_o2","_v"];
_o1 = _this select 0;
_o2 = _this select 1;
_v = _o2 worldToModelVisual [0,0,0];
[
_o2 worldToModelVisual vectorDirVisual _o1 vectorDiff _v,
_o2 worldToModelVisual vectorUpVisual _o1 vectorDiff _v
]
};
[child,parent] call KK_fnc_attachToRelative;
*/