Yeti1 1 Posted September 2, 2012 (edited) I have been watching videos and searching for a while but I can't seem to find a simple explanation of how to use a trigger, when walked into, to spawn a flying plane. My plan is to have it spawn and use waypoints. I am using Arma 2 OA. (Combined Operations) Edited September 2, 2012 by Yeti1 Share this post Link to post Share on other sites
kylania 568 Posted September 2, 2012 This example from a few days ago shows that. Share this post Link to post Share on other sites
Yeti1 1 Posted September 2, 2012 This example from a few days ago shows that. Thanks for that bud, I used this and changed the spawn point to my own marker name, I am a little confused about the waypoints though, how would I add/edit them to make my own path ? GroupA10 = CreateGroup West; A10CAS1 = createVehicle ["A10", [(getMarkerPos "A10Spawn1") select 0,(getMarkerPos "A10Spawn1") select 1,100], [], 0, "FLY"]; A10Pilot = GroupA10 createUnit ["USMC_Soldier_Pilot", [0,0,1], [], 0, "CAN_COLLIDE"]; A10Pilot moveInDriver A10CAS1; Mdir=markerdir "A10Spawn1"; A10CAS1vel = velocity A10CAS1; A10CAS1speed = speed A10CAS1; A10CAS1 setVelocity [(A10CAS1vel select 0)+(sin Mdir*A10CAS1speed),(A10CAS1vel select 1)+ (cos Mdir*A10CAS1speed),(A10CAS1vel select 2)]; A10CAS1 setdir Mdir; wp1 = GroupA10 addWaypoint [(getmarkerpos "A10Target1"), 0]; wp1 setWaypointSpeed "NORMAL"; wp1 setWaypointType "SAD"; Share this post Link to post Share on other sites
kylania 568 Posted September 2, 2012 (edited) You're using the complicated silly version. I didn't link that. :) Here's a demo mission to see it in action without manually spawning guys and throwing vehicles around with math. The waypoints you'd just add more if you wanted more using more addWaypoint and setWaypointBlah commands. If you have some preset path you wanted to use just use the copyWaypoints from an existing unit for that. I'll look for an example of that, I got one somewhere I think. Place down a unit which has the waypoints you want to use. Put this in it's init field: pathMaker = group this; deleteVehicle this; That will place a unit, assign it's waypoints to the "pathMaker" group, than delete the unit. The group and it's waypoints will remember however and be able to be applied to another group via the following command. Then to make a group follow those waypoints use this command: newGroup copyWaypoints pathMaker; The group will begin to follow the path that the unit you had placed had. Edited September 2, 2012 by kylania Share this post Link to post Share on other sites
Yeti1 1 Posted September 2, 2012 (edited) You're using the complicated silly version. I didn't link that. :)Here's a demo mission to see it in action without manually spawning guys and throwing vehicles around with math. Thank you so much, that's just what I needed. EDIT: Thanks for the extra info about waypoints as well bud. ---------- Post added at 23:45 ---------- Previous post was at 23:44 ---------- Managed to get it working almost.. I am aiming for this plane to crash just behind the 'crash1' vehicle, however when I test it the plane starts to fall and doesn't seem to be heading toward the crash1 waypoint I told it too. C130JCAS = createGroup west; C130JCAS = [getMarkerPos "spawn1", [getMarkerPos "spawn1", getPos Crash1] call BIS_fnc_dirTo, "C130J", WEST] call BIS_fnc_spawnVehicle; C130JCAS1 = C130JCAS select 0; C130JCAS1 setPosATL [getPosATL C130JCAS1 select 0, getPosATL C130JCAS1 select 1, 300]; GroupC130J = C130JCAS select 2; wp1 = GroupC130J addWaypoint [(getpos Crash1), 0]; wp1 setWaypointSpeed "FAST"; wp1 setWaypointType "SAD"; hint "Watch your face!" Edited September 2, 2012 by Yeti1 Share this post Link to post Share on other sites
kylania 568 Posted September 2, 2012 Make sure you have BLUFOR units on the map already. If it's falling from the sky it's probably not making pilots properly. Also make sure Crash1 is an object. If that's a marker you'll need to change it to getMarkerPos "Crash1". Share this post Link to post Share on other sites
riouken 15 Posted September 3, 2012 He might be talking about how they start at 0 speed, so even though you spawn it in at 300 etc... It takes the plane a minite to gain enough speed to fly, so it drops quite a bit of altitude at first. One way to fix that is with: http://community.bistudio.com/wiki/setVelocity You can play around with the speed to get it to look better. C130JCAS1 setVelocity [175, 0, 0]; Share this post Link to post Share on other sites
kylania 568 Posted September 3, 2012 You don't need setVelocity or math or magical wishes with spawnVehicle. Keep things simple. :) Share this post Link to post Share on other sites
riouken 15 Posted September 3, 2012 Although I normally just start them a little higher to give them enough time to fly, sometimes it may not fit in with what your trying to do:cool:. Share this post Link to post Share on other sites
twirly 11 Posted September 3, 2012 Try it this way for setting the velocity... if you choose to use it. _dir = direction _aircraft; _aircraft setVelocity [sin(_dir)*90,cos(_dir)*90,0]; Share this post Link to post Share on other sites
Yeti1 1 Posted September 3, 2012 (edited) Thanks for this, I managed to get it to use a waypoint system, I have been trying to give the plane a name so I can adjust the waypoints altitude but I can't seem to figure it out, any ideas ? FYI: What I am trying to achieve is have the plane spawn, come flying over the players position at an airfield then crash at a set location. I have figured out the rest, all I need is to give the plane I spawned using a trigger a name ? Edited September 3, 2012 by Yeti1 Share this post Link to post Share on other sites
twirly 11 Posted September 3, 2012 From post #3 above.... [color="#FF0000"]A10CAS1[/color] = createVehicle ["A10", [(getMarkerPos "A10Spawn1") select 0,(getMarkerPos "A10Spawn1") select 1,100], [], 0, "FLY"]; A10CAS1 would be the planes name. This is a Global variable which you can use in any script or anywhere in the mission. If you had made a Local variable and called it _A10CAS1 (with the underscore) then you could only use it in the script that it occurs in. It is local to that script. Share this post Link to post Share on other sites
Yeti1 1 Posted September 4, 2012 From post #3 above.... [color="#FF0000"]A10CAS1[/color] = createVehicle ["A10", [(getMarkerPos "A10Spawn1") select 0,(getMarkerPos "A10Spawn1") select 1,100], [], 0, "FLY"]; A10CAS1 would be the planes name. This is a Global variable which you can use in any script or anywhere in the mission. If you had made a Local variable and called it _A10CAS1 (with the underscore) then you could only use it in the script that it occurs in. It is local to that script. Thanks bud. Share this post Link to post Share on other sites
Yeti1 1 Posted September 4, 2012 Ok I have totally messed things up, I will be honest I think I tried to jump in the deep end of this, way too deep. I am going to try and make a heli spawn on a trigger then land (I have noticed heli's are a bit different, but it sounds easier). Any advice welcomed, going to search for posts and stuff now anywho. Share this post Link to post Share on other sites
kylania 568 Posted September 4, 2012 This demo mission has several examples of helicopters landing, picking people up, dropping them off and all that. Not sure it's 100% MP safe though. :) Share this post Link to post Share on other sites
Yeti1 1 Posted September 4, 2012 (edited) This demo mission has several examples of helicopters landing, picking people up, dropping them off and all that. Not sure it's 100% MP safe though. :) Thanks for that bud, Just had a little look and it is definitely going to help with quite a lot of points, I couldn't see any trigger spawned stuff though, that is where I need to learn the most because of what I need it for, like hitting a trigger then making a heli spawn and land, if you know of any such missions that would be great, or point me in the direction to get them so I don't keep annoying you :) Edited because I simply forgot to add the function on my map. Edited September 4, 2012 by Yeti1 Share this post Link to post Share on other sites
kylania 568 Posted September 4, 2012 The ending of the mission is trigger based. It causes the editor placed LittleBird to fly out to the extraction point. Share this post Link to post Share on other sites
Yeti1 1 Posted September 4, 2012 The ending of the mission is trigger based. It causes the editor placed LittleBird to fly out to the extraction point. Ahh I see it now, the only thing is that's based on triggers from radio commands and is pretty complex for me just now, I am aiming for a simple 'present' trigger to spawn a heli then make it land. I managed to get a lada to spawn and use waypoints to drive around using the method you gave me earlier, when I try this with the heli it doesn't seem to want to go to the waypoints, it just hovers around. Heli1 = createGroup west; Heli1 = [getMarkerPos "spawn1", [getMarkerPos "spawn1", getPos target1] call BIS_fnc_dirTo, "AH64D", WEST] call BIS_fnc_spawnVehicle; Heli11 = Heli1 select 0; Heli11 setPosATL [getPosATL Heli11 select 0, getPosATL Heli11 select 1, 20]; GroupAH64D = Heli1 select 2; Hint "Test"; Heli11 copyWaypoints pathMaker; Thats the code I have used for my trigger, I know it's probably really simple but I can't put my nooby finger on it. Share this post Link to post Share on other sites
twirly 11 Posted September 5, 2012 (edited) Have a look at this little test mission I did for you. Also... if you lay out your code like this it will be much easier to read. PHP or CODE tags are fine. Either one. //spawn helicopter with crew _array = [[(getMarkerPos "spawn1") select 0,(getMarkerPos "spawn1") select 1,50], 180, "AH64D", WEST] call bis_fnc_spawnvehicle; _heli1 = _array select 0; //the helicopter _helicrew = _array select 1; //the units that make up the crew _heligroup = _array select 2; //the group _wp1 = _heligroup addWaypoint [getMarkerPos "waypoint1", 0]; //waypoint 1 _wp2 = _heligroup addWaypoint [getMarkerPos "waypoint2", 0]; //waypoint 2 _wp3 = _heligroup addWaypoint [getMarkerPos "waypoint3", 0]; //waypoint 3 _wp4 = _heligroup addWaypoint [getMarkerPos "waypoint4", 0]; //waypoint 4 _wp4 setwaypointtype "CYCLE"; //set last waypoint to "cycle" to repeat the waypoints indefinately Now...notice the variables used are Local to that particular script (they have the underscore). They won't work outside this script. If you wanted to refer to the helicopter in another script... make the variable for the helicopter Global by removing the underscore. For example... [b]heli1[/b] = _array select 0; Now you can use heli1 in another script or trigger. Hope it helps you in some way... I know you are trying hard to understand so glad to help! EDIT: Just ran this through all the waypoints to check something and the "CYCLE" waypoint will not make it go back to the start waypoint. Don't use it much so forgot about this.... http://community.bistudio.com/wiki/Mission_Editor:_Waypoints#Cycle It will cycle to the nearest waypoint.... which may not be the start. Edited September 5, 2012 by twirly Clarity Share this post Link to post Share on other sites
Yeti1 1 Posted September 5, 2012 Have a look at this little test mission I did for you.Also... if you lay out your code like this it will be much easier to read. PHP or CODE tags are fine. Either one. Thank you bud, now I understand the basics of scripts, I have a quick question.. 1. How would I change the height of the heli in the waypoints to give it different heights where I wanted? Share this post Link to post Share on other sites
kylania 568 Posted September 5, 2012 Use the flyInHeight command. Share this post Link to post Share on other sites
Yeti1 1 Posted September 5, 2012 Use the flyInHeight command. How would I attach it to a waypoint, there are only markers on the map and they have no space for any code? Share this post Link to post Share on other sites
kylania 568 Posted September 5, 2012 In the OnAct field of the waypoint put: nameOfHelo flyInHeight 60; Share this post Link to post Share on other sites
Yeti1 1 Posted September 6, 2012 Thanks all for the help, finally got it working and it looks good, now to try and start my mod. Share this post Link to post Share on other sites