Jump to content
gitrinec

Spawn a single unit and move them into a vehicle

Recommended Posts

I'm trying to spawn a vehicle and assign an ai driver at the same time but I have had an issue with making the unit spawn into the vehicle. 

So far this is what I've tried. I tried "NONE" as well for the create group. The Bus spawns correctly, just no driver at all or in the bus. 

private["_position","_direction","_veh","_texture","_civgroup"];
createMarker ["Bus_Spawn",[3238.332,6685.015]];
"Bus_Spawn" setMarkerType "Empty";
"Bus_Spawn" setMarkerSize [20, 20];
_position = getMarkerPos "Bus_Spawn";
_direction = 5.994,359.713,357.128;
_veh = createVehicle ["CUP_C_Bus_City_TKCIV", _position, [], 0, "NONE"];
_veh setVehicleVarName "Bus1";
_civgroup = createGroup [civilian,true];
_BusDriver = "C_Man_UntilityWorker_01_F";
_tempBDriver = _civgroup createUnit [_BusDriver, getMarkerPos "Bus_Spawn", [], 0,"CAN_COLLIDE"];
[_tempBDriver] joinSilent _civgroup;
_tempBDriver assignAsDriver _veh;
_tempBDriver moveInDriver _veh;

 

Share this post


Link to post
Share on other sites

A typo here:

write "C_Man_UtilityWorker_01_F" instead of "C_Man_UntilityWorker_01_F"

 

_direction = 5.994,359.713,357.128;

has no sense and no utility

 

Why do you create an empty marker (you could use the position) and why do you give it a size?

Share this post


Link to post
Share on other sites
16 minutes ago, pierremgi said:

A typo here:

write "C_Man_UtilityWorker_01_F" instead of "C_Man_UntilityWorker_01_F"

 

_direction = 5.994,359.713,357.128;

has no sense and no utility

 

Why do you create an empty marker (you could use the position) and why do you give it a size?

I wasn't sure if the size was needed for anything. 

So would this be how you would do the position then?

_veh = createVehicle ["CUP_C_Bus_City_TKCIV",[3238.332,6685.015], [], 0, "NONE"];

Sorry, I left the use of _direction out of the code. Is the direction not needed if you have the position?  It does put the vehicle facing the correct way.

_veh setDir _direction;

 

I guess a bad typo messes up everything with unit creation, thanks!

Share this post


Link to post
Share on other sites

If you want the vehicle facing a specific direction, yes. However, the value you have for _direction is nonsensical. It should be a heading between 0-359.

 

 

Share this post


Link to post
Share on other sites
Just now, Harzach said:

If you want the vehicle facing a specific direction, yes. However, the value you have for _direction is nonsensical. It should be a heading between 0-359.

 

 

It's weird that it works though, I took the values from Rotation in the Attributes of a vehicle I placed to get them originally.

Share this post


Link to post
Share on other sites

Is there a way to take a position such as 3238.332,6685.015 and use that to send a unit to it instead of creating a marker at the location and then sending them there?

Share this post


Link to post
Share on other sites
_direction = 5.994,359.713,357.128;
_veh setDir _direction;

_direction in this case looks like an array without the square brackets. Regardless, a direction is a single number. setDir is taking the first value - 5.994 - and discarding the rest.

_direction = 5.994; // might as well be 6
_veh setDir _direction;

 

 

2 minutes ago, gitrinec said:

Is there a way

 

https://community.bistudio.com/wiki/move

_unit move [3238.332,6685.015];

 

Share this post


Link to post
Share on other sites
16 minutes ago, gitrinec said:

I took the values from Rotation in the Attributes

 

xx8gFcH.png

Share this post


Link to post
Share on other sites
5 minutes ago, Harzach said:

 

xx8gFcH.png

This bus I am using has an x,y in the rotation and no Z

Share this post


Link to post
Share on other sites

Then the Z is 0. X and Y are pitch and roll.

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

×