Jump to content
Sign in to follow this  
Myn

createUnit not spawning vehicles

Recommended Posts

Good evening all.

I have a bit of a pathetic bug which has now been driving me slowly insane for several hours. I'm attempting to spawn an aircraft with createUnit, which I've got to work with createVehicle, but I'd prefer a manned vehicle. Code is as follows:

grp = createGroup west;
wktest = "vbs2_GB_ARMY_Watchkeeper" createUnit [position player, grp];
[player] join grp;
wp = grp addWaypoint [[getPos player select 0, (getPos player select 1)+50, 1000], 0];
[grp, 0] setWaypointType "MOVE";

As the more observant may have noticed, I'm using VBS2, but I've found the community here to be a bit faster to ask. ;) You'll have to trust me that "vbs2_GB_ARMY_Watchkeeper" is real, and this does work with:

 wktest = "vbs2_GB_ARMY_Watchkeeper" createVehicle (position player);

I should know this but my mind's given up on me today.

Any and all responses greatly appreciated, I'll post some cake to you. :)

Cheers,

M

(I should add that despite the phrase "I'd prefer a manned vehicle", obviously the WK450 is an Unmanned Aerial Vehicle, but it does need to be a "manned" vehicle for the purposes of it working with the engine. :) )

Edited by Myn

Share this post


Link to post
Share on other sites

I've noticed this too, CreateUnit Array or CreateUnit do not spawn manned vehicles like you think they would.

Just doesn't even try to spawn anything.

Share this post


Link to post
Share on other sites

You might need to createVehicle it, then createUnit a few units and move them into the vehicle perhaps.

Share this post


Link to post
Share on other sites
You might need to createVehicle it, then createUnit a few units and move them into the vehicle perhaps.

causes so much extra work, I wish BIS would fix this. createUnit on the BIS Wiki says that it will create any unit that is in CfgVehicles... well it doesn't.

Share this post


Link to post
Share on other sites

I am a bit confused with this thread. createUnit creates an instance of a "biological" unit class that is inside CfgVehicles. I think that refers to men, women, and animals only, or am I mistaken? http://browser.dev-heaven.net/cfg_vehicles/classlist?version=24

Yeah I know the Biki doesn't specify biological specifically, but I had always assumed that was the case. When I want a crew inside a vehicle spawned, I do it this way:

_newVeh = createVehicle [_vehicle, [_posx, _posy, _posz], [], 0, _special];
_newVeh setDir _heading;

// create crew
if (_crew) then
{
_group = createGroup _side;
[_newVeh, _group] call BIS_fnc_spawnCrew;
};

The Functions modules must be placed on the map. BIS_fnc_spawnCrew handles the details. Easy as pie.

I have no idea if VBS2 uses the functions module.

Share this post


Link to post
Share on other sites

@Kylania:

Mm that's what I was thinking, and it's what I usually do when I'm playing ARMA II, but with the VBS2 project I'm working on it becomes an issue; I'm basically generating scripts from a remote server and uploading them into the engine to be executed line-by-line, so every extra chunk of code puts a bit of a performance overhead in.

@AZCoder

I'm actually not sure; I had assumed, as GossamerS did, that createUnit would work with every entity in CfgVehicles. Looking at the script from the mission editor I noticed that there was the code:

_vehicle_0 = ["_vehicle_0", true, "vbs2_GB_ARMY_Watchkeeper", etc....] call _func_COC_Vehicle_Create;

Which may be the equivalent to BIS_fnc_spawnCrew, but the script does go on to individually create a driver, gunner, and commander for the vehicle.

Share this post


Link to post
Share on other sites

Just to update this, I've ended up having to use createVehicle and create an independent driver to attach afterwards. Thanks for your help everyone. :)

M

Share this post


Link to post
Share on other sites
In the future, this function can be used to simplify the manned vehicle spawning process for you.

This was also suggested a few posts up. I appreciate that this is a good solution for ARMA II, and is of course relevant for these forums, however I should add for anyone in the same position as me that this function is not supported by VBS2. It will come in very handy when I'm playing around on ARMA II, but for VBS2 I'll just have to stick to the old fashioned way. :) Thank you anyway. :)

Share this post


Link to post
Share on other sites
This was also suggested a few posts up. I appreciate that this is a good solution for ARMA II, and is of course relevant for these forums, however I should add for anyone in the same position as me that this function is not supported by VBS2. It will come in very handy when I'm playing around on ARMA II, but for VBS2 I'll just have to stick to the old fashioned way. :) Thank you anyway. :)

You might still extract the function from the BIS module and include it to your mission, forming your own function with. AFAIK ArmA 2 commands should almost always work with VBS2 but not the other way around (as some commands are VBS2 exclusive).

So even without the module being present you can still use the code itself. You just have to include it yourself.

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
Sign in to follow this  

×