sarogahtyp 1105 Posted May 13, 2016 (edited) Hey guys, i m spawning a hunter with this code: { // for each vehicle _vec = createVehicle [(_x select 0), [0, 0, 0], [], 0, "NONE"]; _vec setPosASL ((_x select 1) vectorAdd [0,0,1]); } forEach _all_vec_info; the problem is that neither me as player nor any AI can turn the engine on and drive it. I dont understand it. If I test it then I see the hunter spawning, geting in it and try to move forward with "W" but nothing happens. I can change the front wheel direction but the engine is not turning on.I tried to choose "Engine On" from action menu. The engine sign in the hud is switching to white shortly and instantly switchs to grey. Idk what is causing that strange behavior. any help woul be appreciated. EDIT: I tested it with a Quad with the same result. I tested if there is fuel in it and the fuel value is nearly 1 I tested to add the vec to my group with debug console with following command: (group player) addVehicle (vehicle player); same strange result.... Testing environment is preview in 2D editor stable branch (not dev). After Fiddis post I testet do disable and enable Simulation via debug console ... doesnt help.tryteyker requested structure of _all_vec_info. it looks like this if 3 vehicles r stored in it: [[type, pos, vectorDir , ... ], [type, pos, vectorDir , ... ], [type, pos, vectorDir , ...]] Edited May 14, 2016 by sarogahtyp Share this post Link to post Share on other sites
Fiddi 68 Posted May 13, 2016 (edited) I've also experienced this, although in a different situation. Mine was after using attachTo and detach, with disable simulation and damage vice versa. Though this was with editor placed vehicles, also in multiplayer it was the host that couldn't start the engine, but clients could. When clients drove around in said vehicle the host couldn't hear engine noise. EDIT In the respawn script I'm using I also used setPosASL. That's the only similarities we're using, I can't test it now, but maybe try it :) EDIT2: Might aswell upload my scripts also for good measure. /* Author: Fredrik Description: Loads nearby quad(s) in Huron helicopter. Parameter: 0 : OBJECT - Player or caller. 1 : OBJECT - Helicopter (HURON) Returns: NOTHING Example: [player, this] spawn FRED_fnc_loadQuad; */ if (!isServer) exitwith {}; private ["_Quads", "_Quad1", "_Quad2"]; params [ ["_Player", objNull, [objNull]], ["_Huron", objNull, [objNull]] ]; _Quads = nearestObjects [_Huron, ["Quadbike_01_base_F"], 25]; if (count _Quads isEqualTo 0) exitWith {}; _Quad1 = _Quads select 0; _Quad2 = if (count _Quads > 1) then {_Quads select 1} else {objNull}; if (_Huron doorPhase "door_rear_source" isEqualTo 0) then { [_Huron, ["door_rear_source", 1, false]] remoteExec ["animateDoor"]; waitUntil {_Huron doorPhase "door_rear_source" isEqualTo 1}; }; [_Quad1, false] remoteExec ["engineOn"]; [_Quad1, false] remoteExec ["setPilotLight"]; _Quad1 attachTo [_Huron,[-0.1,1.25,-0.75]]; Sleep 0.5; [_Quad1, 180] remoteExec ["setDir"]; [_Quad1, false] remoteExec ["enableRopeAttach"]; [_Quad1, false] remoteExec ["enableSimulation"]; if (!isNull _Quad2) exitWith { [_Quad2, false] remoteExec ["engineOn"]; [_Quad2, false] remoteExec ["setPilotLight"]; _Quad2 attachTo [_Huron, [-0.1,-1.25,-0.75]]; Sleep 0.5; [_Quad2, 180] remoteExec ["setDir"]; [_Quad2, false] remoteExec ["enableRopeAttach"]; [_Quad2, false] remoteExec ["enableSimulation"]; ["QuadLogistics",["2 Quadbikes Loaded."]] remoteExec ["BIS_fnc_showNotification", _Player]; }; ["QuadLogistics",["Quadbike Loaded."]] remoteExec ["BIS_fnc_showNotification", _Player]; /* Author: Fredrik Description: Ejects loaded quad(s) in Huron helicopter. Parameter: 0 : OBJECT - Player or caller. 1 : OBJECT - Helicopter (HURON) Returns: NOTHING Example: [player, this] spawn FRED_fnc_ejectQuad; */ if (!isServer) exitwith {}; private ["_chute1","_smoke1","_flare1","_chute2","_smoke2","_flare2"]; params [ ["_Player", objNull, [objNull]], ["_Huron", objNull, [objNull]] ]; _Quad1 = attachedObjects _Huron select 0; _Quad2 = if (count attachedObjects _Huron > 1) then {attachedObjects _Huron select 1} else {objNull}; if (_Huron doorPhase "door_rear_source" isEqualTo 0) then { [_Huron, ["door_rear_source", 1, false]] remoteExec ["animateDoor"]; waitUntil {_Huron doorPhase "door_rear_source" isEqualTo 1}; }; if (!isNull _Quad2) then { [_Quad2, false] remoteExec ["allowDamage"]; [_Quad2, true] remoteExec ["enableSimulation"]; detach _Quad2; if (speed _Huron > 15) then { [_Quad2, [(sin (getDir _Huron -180)) * 5, (cos (getDir _Huron -180)) * 5, 0.5]] remoteExec ["setVelocity"]; } else { [_Quad2, [(sin (getDir _Huron -180)) * 20, (cos (getDir _Huron -180)) * 20, 0.5]] remoteExec ["setVelocity"]; }; [_Quad2, true] remoteExec ["allowDamage"]; if ((getPos _Quad2 select 2) > 30) then { Sleep 1; _chute2 = createVehicle ["B_Parachute_02_F",getPos _Quad2,[],0,"FLY"]; _chute2 setPos (getPos _Quad2); [_chute2, getDir _Quad2] remoteExec ["setDir"]; _Quad2 attachTo [_chute2,[0,0,0]]; _smoke2 = "SmokeShellGreen" createVehicle (getPos _chute2); _smoke2 attachTo [_chute2, [0,0,1]]; _flare2 = "F_40mm_Green" createVehicle (getPos _chute2); _flare2 attachTo [_chute2, [0,0,1]]; [_Quad2, _chute2, _smoke2, _flare2] spawn { params [ ["_Quad2", objNull, [objNull]], ["_chute2", objNull, [objNull]], ["_smoke2", objNull, [objNull]], ["_flare2", objNull, [objNull]] ]; if (!isNil "_chute2") then { waitUntil {Sleep 0.5; (getPos _Quad2 select 2) < 3}; detach _Quad2; detach _smoke2; detach _flare2; }; }; }; [_Quad2, true] remoteExec ["enableRopeAttach"]; if (!isNil "_chute2") then {Sleep 5}; Sleep 0.5; }; [_Quad1, false] remoteExec ["allowDamage"]; [_Quad1, true] remoteExec ["enableSimulation"]; detach _Quad1; if (speed _Huron > 15) then { [_Quad1, [(sin (getDir _Huron -180)) * 5, (cos (getDir _Huron -180)) * 5, 0.5]] remoteExec ["setVelocity"]; } else { [_Quad1, [(sin (getDir _Huron -180)) * 20, (cos (getDir _Huron -180)) * 20, 0.5]] remoteExec ["setVelocity"]; }; [_Quad1, true] remoteExec ["allowDamage"]; if ((getPos _Quad1 select 2) > 30) then { Sleep 1; _chute1 = createVehicle ["B_Parachute_02_F",getPos _Quad1,[],0,"FLY"]; _chute1 setPos (getPos _Quad1); [_chute1, getDir _Quad1] remoteExec ["setDir"]; _Quad1 attachTo [_chute1,[0,0,0]]; _chute1 setDir (getDir _Quad1); _smoke1 = "SmokeShellRed" createVehicle (getPos _chute1); _smoke1 attachTo [_chute1, [0,0,1]]; _flare1 = "F_40mm_Red" createVehicle (getPos _chute1); _flare1 attachTo [_chute1, [0,0,1]]; if (!isNull _Quad2) then { ["QuadLogistics",["Quadbikes Ejected."]] remoteExec ["BIS_fnc_showNotification", _Player]; } else { ["QuadLogistics",["Quadbike Ejected."]] remoteExec ["BIS_fnc_showNotification", _Player]; }; } else { if (!isNull _Quad2) then { ["QuadLogistics",["Quadbikes Unloaded."]] remoteExec ["BIS_fnc_showNotification", _Player]; } else { ["QuadLogistics",["Quadbike Unloaded."]] remoteExec ["BIS_fnc_showNotification", _Player]; }; }; if (!isNil "_chute1") then { waitUntil {Sleep 0.5; (getPos _Quad1 select 2) < 3}; detach _Quad1; detach _smoke1; detach _flare1; }; [_Quad1, true] remoteExec ["enableRopeAttach"]; Edited May 13, 2016 by Fiddi 1 Share this post Link to post Share on other sites
sarogahtyp 1105 Posted May 13, 2016 (edited) hmm, thats weird. if I sit in that not working hunter and do this in debug console: _vec = createVehicle [(typeOf vehicle player), position player, [], 0, "NONE"]; then the new spawned hunter is working without that strange behavior... i m still testing EDIT: now I tried this with debug console: _vec = createVehicle [(typeOf vehicle player), [0,0,0], [], 0, "NONE"]; _vec setPosASL ((getPosASL vehicle player) vectorAdd [5,5,0]); it spawned a full working hunter, too. that means the reason cant be setPosASL but idk what i m doin wrong when i do the nearly same thing via script Edited May 13, 2016 by sarogahtyp Share this post Link to post Share on other sites
tryteyker 28 Posted May 13, 2016 What does _all_vec_info look like? Just trying to get an idea what you're pulling with _x select 0 and _x select 1. 1 Share this post Link to post Share on other sites
sarogahtyp 1105 Posted May 13, 2016 What does _all_vec_info look like? Just trying to get an idea what you're pulling with _x select 0 and _x select 1. it is set up in this script: /* File fn_build_vec_info_array.sqf Title: Spawn Script Creator Author: Sarogahtyp Description: Builds an array with all informations of all vehicles which can be used for spawning Argument: none Return value: array */ if (isNil "saro_SSC_leader_array") exitWith {true}; if (count saro_SSC_leader_array == 0) exitWith {true}; private ["_vec", "_vec_index"]; private _all_vecs_info = []; private _all_vecs = []; { { _vec = vehicle _x; if ((_vec != _x) and !(_vec in _all_vecs)) then { _vec_index = _all_vecs pushBack _vec; _vec setVariable ["vec_index", _vec_index]; _all_vecs_info pushBack (_vec call saroSSC_fnc_get_vec_info); }; }forEach units _x; }forEach saro_SSC_leader_array; _all_vecs_info which calls this script (saroSSC_fnc_get_vec_info): /* File fn_get_vec_info.sqf Title: Spawn Script Creator Author: Sarogahtyp Description: Gets all info bout one vehicle Argument: object - the vehicle Return value: array with all info about that vehicle with this structure: [ string, - 0 class name [number, number, number], - 1 position ASL [number, number, number], - 2 vector dir [number, number, number], - 3 vector up number, - 4 damage number, - 5 fuel boolean, - 6 isEngineOn ]; */ if (isNil "saro_SSC_leader_array") exitWith {true}; if (count saro_SSC_leader_array == 0) exitWith {true}; params[["_vec", objNull, [objNull]]]; if (isNull _vec) exitWith {true}; private _info_array = []; _info_array pushBack (typeOf _vec); _info_array pushBack (getPosASL _vec); _info_array pushBack (vectorDir _vec); _info_array pushBack (vectorUp _vec); _info_array pushBack damage _vec; _info_array pushBack fuel _vec; _info_array pushBack isEngineOn _vec; _info_array after all the strucure looks like this if the info of 3 vehicles was stored in it: [[type, pos, vectorDir , ... ], [type, pos, vectorDir , ... ], [type, pos, vectorDir , ... ]] Share this post Link to post Share on other sites
tryteyker 28 Posted May 13, 2016 I've had this problem before too, but can't actually remember how I fixed it, if at all. Just threw your loop into a mission with the general array structure you mentioned and it all works fine on my end. How are you executing the foreach loop? I'm using a standalone sqf script but if you're executing it within a bigger script that may offer a clue as to what's wrong. Otherwise, since you're spawning it 1m up in the air, make sure all stats are white (ie engine etc) as the vehicle might've just broken down while it was dropped from the air. I honestly have no idea what might cause the engine to just not work at all script-wise so I'm just throwing random ideas into the room here. 1 Share this post Link to post Share on other sites
sarogahtyp 1105 Posted May 13, 2016 the 1 m up spawning causes no damage. it was just a try to fix the problem. i ll post the complete spawning script tomorrow because i m at work now. i could throw a mission file to dropbox tomorrow, too. the problem gets me stuck in my development of a script package therefore a solution is really needed... Share this post Link to post Share on other sites
sarogahtyp 1105 Posted May 14, 2016 okay, thanks for ur help, its solved. finally it was very easy i should have done that much earlyer... i substituted this code: { // for each vehicle _vec = createVehicle [(_x select 0), [0, 0, 0], [], 0, "NONE"]; _vec setPosASL ((_x select 1) vectorAdd [0,0,1]); } forEach _all_vec_info; with this: { // for each vehicle _vec = createVehicle [(_x select 0), (_x select 1), [], 0, "NONE"]; // _vec setPosASL ((_x select 1) vectorAdd [0,0,1]); } forEach _all_vec_info; now its working. that is strange because spawning at [0, 0, 0] and then using setPos is the recommended method to spawn because it should be faster. could be a BUG with setPosASL instantly after spawning a vehicle. Share this post Link to post Share on other sites
Fiddi 68 Posted May 14, 2016 How about if you did this: { // for each vehicle _vec = createVehicle [(_x select 0), [0, 0, 0], [], 0, "NONE"]; _vec setPos (_x select 1); } forEach _all_vec_info; Was it still the same? 1 Share this post Link to post Share on other sites
sarogahtyp 1105 Posted May 14, 2016 How about if you did this: { // for each vehicle _vec = createVehicle [(_x select 0), [0, 0, 0], [], 0, "NONE"]; _vec setPos (_x select 1); } forEach _all_vec_info; Was it still the same? tried it now and its the same result as with setPosASL. Engine cant be started after that. Share this post Link to post Share on other sites
Fiddi 68 Posted May 14, 2016 tried it now and its the same result as with setPosASL. Engine cant be started after that. On most island maps [0,0,0] is over or on the water surface. But since it's there for a small moment shouldn't cause the problem, but when in Arma... 2 Share this post Link to post Share on other sites
das attorney 857 Posted May 14, 2016 ^ this. If you spawn it in water, it wrecks the engine. 1 Share this post Link to post Share on other sites
f2k sel 164 Posted May 14, 2016 Correct If the vehicle spawn is in water the engine gets damaged but it damage doesn't show in the hud which is what confuses people. Some vehicles will be fine but others need to be spawned at height or a safe location. 1 Share this post Link to post Share on other sites
sarogahtyp 1105 Posted May 14, 2016 okay guys u gave it a sense but that should be fixed with a delay for wrecking the engine after it is inside of water. Somewhere I read that spawning at [0, 0, 0] and then setPos is a way faster then spawning it directly at that position. Share this post Link to post Share on other sites
das attorney 857 Posted May 14, 2016 Somewhere I read that spawning at [0, 0, 0] and then setPos is a way faster then spawning it directly at that position. idk - you're asking the engine to run 2 scripting commands rather than one. Test it in the debug console and you'll know for sure. 1 Share this post Link to post Share on other sites
Fiddi 68 Posted May 14, 2016 Don't know if this is faster but I found that it works for me, I've adapted it to your code, you can try it if you want. { // for each vehicle _vec = createVehicle [(_x select 0), ASLToAGL [0, 0, 10], [], 0, "NONE"]; _vec setPosASL ((_x select 1) vectorAdd [0,0,1]); } forEach _all_vec_info; I tested in the debug console just now,This is atleast 5 times faster: _veh = "B_MRAP_01_gmg_F" createVehicle ASLToAGL [0,0,10]; _veh setPosASL Spawnpos; than this: _veh = "B_MRAP_01_gmg_F" createVehicle Spawnpos Wonder why, logically the second should be faster or atleast as fast. 1 Share this post Link to post Share on other sites
sarogahtyp 1105 Posted May 14, 2016 idk - you're asking the engine to run 2 scripting commands rather than one. Test it in the debug console and you'll know for sure. i tested it right now and at my slow environment it seems to be about 25 times faster!!! Share this post Link to post Share on other sites
sarogahtyp 1105 Posted May 14, 2016 Don't know if this is faster but I found that it works for me, I've adapted it to your code, you can try it if you want. { // for each vehicle _vec = createVehicle [(_x select 0), ASLToAGL [0, 0, 10], [], 0, "NONE"]; _vec setPosASL ((_x select 1) vectorAdd [0,0,1]); } forEach _all_vec_info; yeah, that is working but its not spawning at [0,0,0] and thats why it should be slower... Share this post Link to post Share on other sites
das attorney 857 Posted May 14, 2016 tbh if you are preoccupied by speed then spawn it where it's supposed to be with "can_collide" parameter. Should be fastest 1 Share this post Link to post Share on other sites
sarogahtyp 1105 Posted May 14, 2016 tbh if you are preoccupied by speed then spawn it where it's supposed to be with "can_collide" parameter. Should be fastest thats an option i ll test and think about if that is a good idea in the case of my scripts achievement. Share this post Link to post Share on other sites
das attorney 857 Posted May 14, 2016 i tested it right now and at my slow environment it seems to be about 25 times faster!!! Did you delete the 10,000 objects before you tried to spawn another 10,000? If not, then that's why.. Share this post Link to post Share on other sites
sarogahtyp 1105 Posted May 14, 2016 NO WAY! "CAN COLLIDE" is as slow as "NONE". the fastest way is spawning at [0,0,0]... Share this post Link to post Share on other sites
sarogahtyp 1105 Posted May 14, 2016 Did you delete the 10,000 objects before you tried to spawn another 10,000? If not, then that's why.. I used the speedometer, it seems to delete automatically because there is no spawned vehicle to see... also i spawned at [0,0,0] after the other methods and it was much faster again. Share this post Link to post Share on other sites
sarogahtyp 1105 Posted May 14, 2016 u can try it urself with these both codes. execute em with the speedometer while u r sitting in a vehicle: _vec = createVehicle [(typeOf vehicle player), [0,0,0], [], 0, "NONE"]; _vec setPosASL ((getPosASL vehicle player) vectorAdd [5,5,0]) _vec = createVehicle [(typeOf vehicle player), ((getPosASL vehicle player) vectorAdd [5,5,0]), [], 0, "NONE"]; Share this post Link to post Share on other sites
das attorney 857 Posted May 14, 2016 I tried this (important to delete the vehicles as you spawn otherwise with "none" param, it will need to be searching for free space when there is thousands of other Hunters spawned there already and fuck up the results. Even though the speed-check will be evaluating deleteVehicle, it appears in all three tested versions and so is a constant). Spawning where you want it to be with "can_collide" works fastest for me. _veh = createVehicle ["B_MRAP_01_F",[0,0,0],[],0,"none"]; _veh setPos [2257,2268,0]; deleteVehicle _veh; 1.19451 ms ----------- _veh = createVehicle ["B_MRAP_01_F",[2257,2268,0],[],0,"none"]; deleteVehicle _veh; 11.6667 ms ​----------- _veh = createVehicle ["B_MRAP_01_F",[2257,2268,0],[],0,"can_collide"]; deleteVehicle _veh; 0.726216 ms 1 Share this post Link to post Share on other sites