Jump to content
lawndartleo

Spawning a vehicle at a specific height

Recommended Posts

So I use the following script to spawn a vehicle on a marker...

 

_slingammo = "B_Slingload_01_Ammo_F" createvehicle (getmarkerpos "huron_pickup");

 

... and this works great over land.  The problem is that I want to have that marker on a ship (carrier in this case) and this doesn't quite work.  The crates are spawning under water so the marker must be attached to the sea floor.  How do I make the object spawn at a specific height, specifically deck carrier deck height? I've gone over the alphabet soup on the BI wiki and its all Greek to me.

 

 

 

 

Share this post


Link to post
Share on other sites

Make sure that the marker is set properly in 3D space in the editor (as in the proper height on the ship) and make this small change to your code. If the first option doesn't work, try the second and change the marked value. Info: getMarkerPos  set

 

_slingammo = "B_Slingload_01_Ammo_F" createvehicle (getmarkerpos ["huron_pickup",true]);

//getMarkerPos ["myMrk",true] returns a position array with [x,y,z]

/////OR

_slingammo = "B_Slingload_01_Ammo_F" createvehicle (getmarkerpos "huron_pickup") set [2,*properHeightOfShipSurface*];
//getMarkerPos "myMrk" returns a position array as [x,y,0]
//subsequently using 'set [2,someNumber]' overwrites that zero to whatever value you input

 

 

EDIT: After seeing that you actually can't easily set the marker height via editor and noticing the return of getMarkerPos [array] is positionAGL you may run into problems since you're on a ship. Second option is your best option.

Edited by jshock
  • Like 2

Share this post


Link to post
Share on other sites
4 hours ago, lawndartleo said:

its all Greek to me.

 

Hello there lawndartleo !

 

You can also see a different approach , check the script below , ask me if you don't understand :

 

Share this post


Link to post
Share on other sites

Use setVehiclePosition should set the vehicle on the first walkable surface( the ship ).

  • Like 1

Share this post


Link to post
Share on other sites

Thanks for the input, everyone.

 

I settled on the below approach simply because it is the one I can get my head around.

 

I don't know if this is the best approach but so far it works for all objects that I have a spawning script for.

 

On an object as an addAction

 

this addAction ["REQUISITION A CARGO NET (ACE ARSENAL)","scripts\huron_cargonet.sqf"]; 

 

The script

_position = getMarkerPos "huron_pickup";

_spCheck = nearestObjects[_position,["B_Slingload_01_Ammo_F","B_Slingload_01_Cargo_F","B_Slingload_01_Fuel_F","B_Slingload_01_Medevac_F","B_Slingload_01_Repair_F","B_CargoNet_01_ammo_F"],500] select 0;
if(!isNil "_spCheck") then {deleteVehicle _spCheck;};

sleep 1;

_cargonet = "B_CargoNet_01_ammo_F" createvehicle (getmarkerpos "huron_pickup");

_cargonet setPosASL [position _cargonet select 0, position _cargonet select 1, 23.75];

clearMagazineCargoGlobal _cargonet;
clearWeaponCargoGlobal _cargonet;
clearItemCargoGlobal _cargonet;

[_cargonet, true] call ace_arsenal_fnc_initBox;

hint "CARGO NET (ACE ARSENAL) DELIVERED!";

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×