Difference between revisions of "lineIntersectsSurfaces"
Killzone Kid (talk | contribs) (example update) |
Das Attorney (talk | contribs) |
||
Line 53: | Line 53: | ||
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]] | [[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]] | ||
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]] | [[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]] | ||
+ | |||
+ | {{subst:Add new note/construct| | ||
+ | |||
+ | You can combine with intersect command to find selection names on intersected objects (in this example priority is geom >> ifire >> fire >> view): | ||
+ | |||
+ | <nowiki>arrow = "Sign_Arrow_F" createVehicle [0,0,0]; | ||
+ | testFunc = { | ||
+ | _ins = lineIntersectsSurfaces [ | ||
+ | ATLToASL positionCameraToWorld [0,0,0], | ||
+ | ATLToASL positionCameraToWorld [0,0,1000], | ||
+ | player | ||
+ | ]; | ||
+ | if (count _ins == 0) exitWith { | ||
+ | arrow setPosASL [0,0,0] | ||
+ | }; | ||
+ | arrow setPosASL (_ins select 0 select 0); | ||
+ | arrow setVectorUp (_ins select 0 select 1); | ||
+ | _sel = ""; | ||
+ | _dist = 10000; | ||
+ | { | ||
+ | _ins2 = [_ins select 0 select 3,_x] intersect [ | ||
+ | positionCameraToWorld [0,0,0], | ||
+ | positionCameraToWorld [0,0,1000] | ||
+ | ]; | ||
+ | |||
+ | { | ||
+ | if (_x select 1 < _dist) then { | ||
+ | _dist = _x select 1; | ||
+ | _sel = _x select 0 | ||
+ | }; | ||
+ | } forEach _ins2; | ||
+ | if (_sel != "") exitWith {}; | ||
+ | } forEach ["geom","ifire","fire","view"]; | ||
+ | |||
+ | hintsilent format ["selection: %1",_sel]; | ||
+ | }; | ||
+ | ["sample_id","onEachFrame","testFunc"] call BIS_fnc_addStackedEventHandler; |
Revision as of 23:17, 12 August 2015
Notes
Bottom Section
{{subst:Add new note/construct|
You can combine with intersect command to find selection names on intersected objects (in this example priority is geom >> ifire >> fire >> view):
<nowiki>arrow = "Sign_Arrow_F" createVehicle [0,0,0];
testFunc = { _ins = lineIntersectsSurfaces [ ATLToASL positionCameraToWorld [0,0,0], ATLToASL positionCameraToWorld [0,0,1000], player ]; if (count _ins == 0) exitWith { arrow setPosASL [0,0,0] }; arrow setPosASL (_ins select 0 select 0); arrow setVectorUp (_ins select 0 select 1); _sel = ""; _dist = 10000; { _ins2 = [_ins select 0 select 3,_x] intersect [ positionCameraToWorld [0,0,0], positionCameraToWorld [0,0,1000] ];
{ if (_x select 1 < _dist) then { _dist = _x select 1; _sel = _x select 0 }; } forEach _ins2; if (_sel != "") exitWith {}; } forEach ["geom","ifire","fire","view"];
hintsilent format ["selection: %1",_sel]; }; ["sample_id","onEachFrame","testFunc"] call BIS_fnc_addStackedEventHandler;