Necropaulo 12 Posted December 18, 2023 Hey everybody, today's problem made me crazy since this morrning 🤣 I'm using Virtual Arsenal on a mission, but when i open it, the camera is behind some object, so i'm trying to change the camera position when opening virtual arsenal, but i can't find any way to do that ! I use this to open the arsenal in a NPC init : [this,"Armurerie", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_loaddevice_ca.paa", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_loaddevice_ca.paa", "_this distance _target < 3","_caller distance _target < 3",{},{}, { ["Open", [true, player]] call BIS_fnc_arsenal; },{},[],2,0,false,false] remoteExec ["BIS_fnc_holdActionAdd", 0, this]; I've find an old topic with this kind of line : Quote BIS_fnc_arsenal_campos_0 = [5,170,18,[0,0,0.85]]; I try to insert it in my initPlayerLocal.sqf but it cause some error Same with this try : Quote BIS_fnc_arsenal_campos = ["Altis",[11544.9,11974.9,3.34449],60.9209,0.75,[-27.6146,0],0,0,383,0.000169478,0,1,0,1]; Some one have an idea to help me ? I just wanna center the view on player, not stuck behind an object 😅 Share this post Link to post Share on other sites
Harzach 2511 Posted December 18, 2023 2 hours ago, Necropaulo said: I've find an old topic with this kind of line : You ignored the context: On 7/5/2023 at 3:41 AM, Robustcolor said: ...use this in initPlayerLocal.sqf, play around with the numbers to change the angle. Remember that this will be overwrited with the new camera angle you set with the mouse inside the arsenal when you exit it. So if you want to reset it to the angle from the script use a arsenalClosed EventHandler. BIS_fnc_arsenal_campos_0 = [5,170,18,[0,0,0.85]]; [missionNamespace, "arsenalClosed", { BIS_fnc_arsenal_campos_0 = [5,170,18,[0,0,0.85]]; }] call BIS_fnc_addScriptedEventHandler; Quote but it cause some error What error? The code as originally presented works fine, so something has gone wrong with your implementation. Share this post Link to post Share on other sites
soldierXXXX 80 Posted December 18, 2023 Hi, solution for this problem is update variable of arsenal camera position based on arsenal system. here is simple code to manually set the camera on fixed position: //easy solution: [missionNamespace, "arsenalOpened", { params ["_display", "_toggleSpace"]; uiNamespace setVariable ["BIS_fnc_arsenal_campos",[8,90,((30 max -89) min 89),[0,0,0.85]]];//fixed position }] call BIS_fnc_addScriptedEventHandler; array is in format [distance of camera, horizontal direction of camera(from -359 to 359),vertical direction of camera (from -89 to 89),target position array (probably modelspace center of object that camera should follow)]. A bit advanced detection if object is in front of camera (not terrain) and if yes then camera will turn by specified number of degrees on the horizontal axis until camera and target object have clear line between them. Be aware it's just a example code put quickly together and would require tweaking, it's not ideal for all situation so first solution will be probably better. I hope it helps 🙂 Spoiler soldierXXXX_fnc_Arsenal_SetCamSafePos = { scriptName "soldierXXXX_fnc_Arsenal_SetCamSafePos"; with uinamespace do { private _cam = uinamespace getvariable ["BIS_fnc_arsenal_cam", objnull]; //if (!isNil {uiNamespace getVariable "BIS_fnc_arsenal_campos";}) exitWith {hint "uinamespace"}; private _type = BIS_fnc_arsenal_type;//uiNamespace getVariable "BIS_fnc_arsenal_type"; private _camPos = BIS_fnc_arsenal_campos;//uiNamespace getVariable "BIS_fnc_arsenal_campos"; private _camDefaultPos = [[10,-45,15,[0,0,-1]], [5,0,0,[0,0,0.85]]] select (_type == 0);//arsenal or garage _camPos params ["_dis", "_dirH", "_dirV", "_targetPos"]; //turnCamera by sphere private _turnStep = 45; private _endTurn = 180; private _remainder = _endTurn%_turnStep; _endTurn = _endTurn - _remainder; for "_i" from 0 to _endTurn step _turnStep do { private _dirH = (_dirH + _turnStep)%360; private _center = missionnamespace getVariable ["BIS_fnc_arsenal_center", player]; private _cam = uinamespace getvariable ["BIS_fnc_arsenal_cam", objnull]; //systemChat str (getPosASLVisual _cam); private _viewBlocked = lineIntersects [getPosASLVisual _cam,getPosASLVisual _center,_cam,_center]; if (!_viewBlocked) exitwith {}; (uiNamespace getVariable "BIS_fnc_arsenal_campos") set [1,_dirH]; sleep 0.1;//to see that it actually turns-remove for instant change }; }; /* _debugEH = addMissionEventHandler ["EachFrame",{ uinamespace getVariable "BIS_fnc_arsenal_campos" params ["_dis", "_dirH", "_dirV", "_targetPos"]; private _mousePos = uinamespace getVariable "BIS_fnc_arsenal_mouse"; systemChat format ["distance:%1 dirH:%2 dirV:%3 target pos:%4 MousePos:%5",_dis,_dirH,_dirV,_targetPos,_mousePos]; }]; */ waitUntil {isNil {uinamespace getVariable "BIS_fnc_arsenal_display"}}; //removeMissionEventHandler ["EachFrame",_debugEH]; }; [missionNamespace, "arsenalOpened", { params ["_display", "_toggleSpace"]; [] spawn soldierXXXX_fnc_Arsenal_SetCamSafePos; // hint message to the player when he opens the Arsenal }] call BIS_fnc_addScriptedEventHandler; 1 Share this post Link to post Share on other sites
Necropaulo 12 Posted December 18, 2023 Ho, i certainly miss something ^^' thank for answer ! I've exactly the same issue than the old topic, i supposed i need to put it in my initplayerlocal but with your answer, i start to understand my error 😊 The part concerning the initplayerlocal.sqf is this one : Quote [missionNamespace, "arsenalClosed", { BIS_fnc_arsenal_campos_0 = [5,170,18,[0,0,0.85]]; }] call BIS_fnc_addScriptedEventHandler; This save the cam to re-open with the good angle. So i suppose that i need to set BIS_fnc_arsenal_campos_0 somewhere else, but i really don't know where. In my holdaction ? EDIT: after soldierXXXX answer I use that in my InitServer.sqf Quote [missionNamespace, "arsenalOpened", {params ["_display", "_toggleSpace"]; uiNamespace setVariable ["BIS_fnc_arsenal_campos ",[8,90,((30 max -89) min 89),[GetPosATL player]]]; }] call BIS_fnc_addScriptedEventHandler; This seem to work, when i close Arsenal then go back in, my camera is good, but at the first opening that's behind the wall 😅 Am i missing something again ? Share this post Link to post Share on other sites
Harzach 2511 Posted December 18, 2023 32 minutes ago, Necropaulo said: Am i missing something again ? initPlayerLocal: BIS_fnc_arsenal_campos_0 = [5,170,18,[0,0,0.85]]; //sets angle for initial opening of Arsenal [missionNamespace, "arsenalClosed", { BIS_fnc_arsenal_campos_0 = [5,170,18,[0,0,0.85]]; }] call BIS_fnc_addScriptedEventHandler; //sets angle for next opening of Arsenal 2 Share this post Link to post Share on other sites
Necropaulo 12 Posted December 18, 2023 Thanks to you two, this is finally working ... I don't know how i can miss that ! really thanks ! 😁 Share this post Link to post Share on other sites
soldierXXXX 80 Posted December 18, 2023 ^ @Harzach's solution except i would change "arsenalClosed" to "arsenalOpened" so it sets the angle immediately without previous declaration. In initServer.sqf nobody except the server would see the result. And Arsenal is run locally so initPlayerLocal.sqf makes much more sense. 2 Share this post Link to post Share on other sites
Harzach 2511 Posted December 18, 2023 Opened makes more sense for sure, I was just demonstrating the solution from the other topic. *edit* - Opened not working, for some reason. No time to figure it out, maybe something on my end. 2 Share this post Link to post Share on other sites
soldierXXXX 80 Posted December 19, 2023 14 hours ago, Harzach said: *edit* - Opened not working, for some reason. No time to figure it out, maybe something on my end. Just to clarify the difference between BIS_fnc_arsenal_campos_0 and BIS_fnc_arsenal_campos BIS_fnc_arsenal_campos_0 is initial position variable that is loaded when arsenal is created so if you want to use this, this should be declared before arsenal is opened just as in your solution. If it's not declared before, arsenal will use default camera position. This variable is also set again when you exit the arsenal so next time you open it it's on the same position you left it, but with use of "arsenalClosed" the variable is updated on that position instead. That's why "arsenalOpened" won't work on this one because when Opened is called, camera is already set. Variable runs in missionNamespace.BIS_fnc_arsenal_campos on the other hand is variable of latest camera position, with which all positioning scripts inside arsenal function works. When arsenal is opened this variable is set based on BIS_fnc_arsenal_campos_0 position first but then exists on it's own until you exit the arsenal. Variable runs in uiNamespace. "arsenalOpened" will work with this variable correctly, because event is called after all variables are set and scripts used in arsenal function will update it's position based on this variable. That's why your solution works with "arsenalClosed" and mine works with "arsenalOpened". 🙂 1 1 Share this post Link to post Share on other sites
Necropaulo 12 Posted December 19, 2023 After some tests, i confirm that Harzach's solution is fine to solve my problem 😊 and, by the way, thanks soldierXXXX too ! I add this in my InitPlayerLocal.sqf : Quote BIS_fnc_arsenal_campos_0 = [5,85,18,[0,0,0.85]]; [missionNamespace, "arsenalClosed", {BIS_fnc_arsenal_campos_0 = [5,85,18,[0,0,0.85]]; }] call BIS_fnc_addScriptedEventHandler; Where "85" is the angle in front of my arsenal, maybe this will help someone else : [5,170,18,[0,0,0.85]] // 3rd person from back [5,85,18,[0,0,0.85]] // 3rd person from right 17 hours ago, soldierXXXX said: array is in format [distance of camera, horizontal direction of camera(from -359 to 359),vertical direction of camera (from -89 to 89),[target position array (probably modelspace center of object that camera should follow)]]. 1 1 Share this post Link to post Share on other sites