Jump to content
Sign in to follow this  
forzajuve

Spawning flying plane

Recommended Posts

Don't know what's wrong with my code. The planes spawn but I think they have no pilot since one flies like 500m in a dive then crashes and the other two just pretty much spawn, drop vertically straight down and then explode.

GroupF35B = CreateGroup West;
F35B1 = createVehicle ["F35B", [(getMarkerPos "US") select 0, (getMarkerPos "US") select 1, 100], [], 0, "FLY"];
F35BPilot = F35B1 createUnit ["USMC_Soldier_Pilot", [0,0,1], [], 0, "CAN_COLLIDE"];
F35BPilot assignAsDriver F35B1;
F35BPilot moveInDriver F35B1;
F35B2 = createVehicle ["F35B", [(getMarkerPos "US") select 0, (getMarkerPos "US") select 1, 100], [], 0, "FLY"];
F35BPilot = F35B2 createUnit ["USMC_Soldier_Pilot", [0,0,1], [], 0, "CAN_COLLIDE"];
F35BPilot assignAsDriver F35B2;
F35BPilot moveInDriver F35B2;
F35B3 = createVehicle ["F35B", [(getMarkerPos "US") select 0, (getMarkerPos "US") select 1, 100], [], 0, "FLY"];
F35BPilot = F35B3 createUnit ["USMC_Soldier_Pilot", [0,0,1], [], 0, "CAN_COLLIDE"];
F35BPilot assignAsDriver F35B3;
F35BPilot moveInDriver F35B3;
wp1 = GroupF35B addWaypoint [(getmarkerpos "waypoint1"), 0];
wp1 setWaypointSpeed "NORMAL";
wp1 setWaypointType "MOVE"; 
wp1 setWaypointStatements ["true", "{deleteVehicle _x} forEach (crew F35B1); deleteVehicle F35B1"; {deleteVehicle _x} forEach (crew F35B2); deleteVehicle F35B2; {deleteVehicle _x} forEach (crew F35B3); deleteVehicle F35B3"];

Share this post


Link to post
Share on other sites

this is what I use to spawn a player into a flying plane on respawn.

feel free to modify as needed.

_unit = _this select 0;

_plane = createVehicle ["I44_Plane_A_P51D_250lb_AAF", getMarkerPos "pl_plane_start", [], 0, "FLY"];
_plane setPosATL [getPosATL _plane select 0, getPosATL _plane select 1, 250];
_plane setDir 80; 
_plane engineOn true;
_plane setVelocity [100,0,0];
_unit moveInDriver _plane;

Share this post


Link to post
Share on other sites

I think yor trying to spawn a jet with ai, not for players?

If so, why not use the BIS function?

[markerPos "some_marker", random 360, "A10", west] call BIS_fnc_spawnVehicle;

Share this post


Link to post
Share on other sites
I think yor trying to spawn a jet with ai, not for players?

If so, why not use the BIS function?

[markerPos "some_marker", random 360, "A10", west] call BIS_fnc_spawnVehicle;

just need to spawn 3 F35s for a flyover on a trigger, then to be deleted.

Share this post


Link to post
Share on other sites

Ok, I tested it. I thought this worked, but it starts flying on ground!

So I did this. and works

Functions module on map first.

Put a marker down where you want spawn jet. Then I went into mission.sqf and got the marker postion

format [x, z, y]

position[]={1507.5386,46.396168,3070.4421};

Then in trigger I put altered z

format [x, y, z]

hog =  [[1507.5386,3070.4421,146.396168], 180, "A10", west] call BIS_fnc_spawnVehicle; jet = hog select 0

Another trigger

{deleteVehicle _x} forEach crew jet + [jet]; hint "bye"

Edited by PlacidPaul

Share this post


Link to post
Share on other sites

I'm lost here, I'm not sure what I do with this function module thing, do I sync it to a trigger or something?? Also how did you get that altered z value, is it flying height or something?

Where does all the code go, in the module or a trigger?

Share this post


Link to post
Share on other sites

Just put module on map, thats it, allows you to use BIS functions. Code goes where you want, I had in radio trig, for testing. I just added 100 to the z value, of where I put marker on map, so jet spawned 100 high.

Share this post


Link to post
Share on other sites

got it working almost perfectly now thanks :) just one problem... how do I change their flight direction? I could change the spawn direction (180 ->325) but the 'west' which seems to be their flight direction I had no success in changing.

---------- Post added at 03:22 ---------- Previous post was at 02:51 ----------

also any idea on how to force units out of a vehicle (heli/truck/boat)? I've tried unload/eject scripts, doGetOut, unit action ["getout",] etc.. nothing works. It all goes haywire when the player is squad leader, I wish there is an easy way to make the units get out automatically. don't like having to force the player to say 'disembark'.

Share this post


Link to post
Share on other sites

West is not the direction, its the side. Look here http://community.bistudio.com/wiki/BIS_fnc_spawnVehicle I assume you would give them a waypoint like you where trying with first post.

This is the returned array.

0: new vehicle (Object).

1: all crew (Array of Objects).

2: vehicle's group (Group).

So use select 1, like you did with select 0, to get the crew name. Then maybe try this

unitnamehere action ["EJECT",vehiclenamehere]

Share this post


Link to post
Share on other sites

the waypoint isn't working, the planes seem to spawn for like 0.5 sec moving in the direction of the waypoint but then delete straight away and then the other planes spawn again and fly in the wrong direction.

f351 = [[4843.4268,9745.875,439], 325, "F35B", west] call BIS_fnc_spawnVehicle; jet = f351 select 0; 

f352 = [[4803.82918,9928.4297,439], 325, "F35B", west] call BIS_fnc_spawnVehicle; jet = F352 select 0; 

f353 = [[4851.752,9875.1172,439], 325, "F35B", west] call BIS_fnc_spawnVehicle; jet = F353 select 0

_wp = f351 addwaypoint [getMarkerPos "m1",0];
_wp setwaypointype "move";

_wp = f352 addwaypoint [getMarkerPos "m1",0];
_wp setwaypointype "move";

_wp = f353 addwaypoint [getMarkerPos "m1",0];
_wp = setwaypointype "move";

---------- Post added at 16:56 ---------- Previous post was at 16:50 ----------

still nothing with that eject command too

Share this post


Link to post
Share on other sites

Ok, I'm doing everything in trigger so I don't use _local variables i'm using global.

trigger one

plane =  [[1507.5386,3070.4421,146.396168], 360, "A10", west] call BIS_fnc_spawnVehicle; jet = plane select 0; grp = plane select 2;  wp1 = grp addwaypoint [getMarkerPos "m1",0]; wp1 setWaypointType "move"; 

trigger two

pilot1 = driver jet; UnAssignVehicle pilot1; pilot1 action ["EJECT", jet];

trigger three

{deleteVehicle _x} forEach crew jet + [jet];

---------- Post added at 09:37 AM ---------- Previous post was at 09:34 AM ----------

Also, I think you have to change the name of wp for each grp

Share this post


Link to post
Share on other sites

got it working now!! thanks :)

---------- Post added at 00:55 ---------- Previous post was at 00:53 ----------

plane = [[4843.4268,9745.875,439], 325, "F35B", west] call BIS_fnc_spawnVehicle; jet = plane select 0; 

plane2 = [[4803.82918,9928.4297,439], 325, "F35B", west] call BIS_fnc_spawnVehicle; jet2 = plane2 

select 0; 

plane3 = [[4851.752,9875.1172,439], 325, "F35B", west] call BIS_fnc_spawnVehicle; jet3 = plane3 select 

0;

grp = plane select 2;  wp1 = grp addwaypoint [getMarkerPos "m1",0]; wp1 setWaypointType "move";
grp = plane2 select 2;  wp1 = grp addwaypoint [getMarkerPos "m2",0]; wp1 setWaypointType "move";
grp = plane3 select 2;  wp1 = grp addwaypoint [getMarkerPos "m3",0]; wp1 setWaypointType "move";

Edited by ForzaJuve

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  

×