Jump to content
Sign in to follow this  

Recommended Posts

when i script the ai pilot to take off from the main airfield in chereraus he alway turns and crashes into some treee just after take-off. how can i stop this???

Share this post


Link to post
Share on other sites

You could try a setvector dir loop script along the runway and then slowly increment his pitch using the setvectordirandup command and then give him a setvelocity push into the air. This would force him to follow a set realistic takeoff path then make sure he has a waypoint to handover to once up and when the script exits.

I do not know how to use scripts with time delays in ArmA 2 though I cannot work out how to simulate the simple old way we did it in .sqs format for Operation Flashpoint. Until someone throws some light on this I can't help you further.

Anyone know how this is done using only .sqf files? Can you use an FSM to do it?

Once that object's surmounted I can make a rough demo script which you can modify if you're still that interested in working on it, or want such a refined solution - there may be a much simpler easier way than what I've suggested.

Share this post


Link to post
Share on other sites

I've blathered on alot about things I've suggested on here long enough so I thought I'd actually do something as it's been too long.

Early stages of scripted takeoff script.

Ok this one is also based on Utes. It used an empty plane with a disabled AI piloted moved into it. A regular plane would work just as well. The player is put in the cockpit next to the pilot. The plane is held by a script which waits for the Alpha signal radio. Once it gets the signal to start through a variable called 'go' the plane uses a while loop to slowly increase the plane's speed, and some trigonometry to keep the plane pointed at the target game logic called 'runwaylogic' you can find on the map.

The plane does not takeoff yet and will either crash or exhibit very weird behaviour once past the game logic. Also if it gets above the specified input speed in the script launch command the script will disengage and the AI will take over and ...... bang.

There's no setpositioning or AI input here at all, all this is done legitimately through the setvector commands to keep the plane upright and a trig altered setdir loop to keep the plane pointed at the target game logic.

Trigonometry was also needed for the setvelocity loop as without it the plane looks like it is skidding towards dead West all the time and the velocity components in the setvelocity loop need updating to keep track of the vehicle's heading changes even when they are quite minor.

Some momentum affected behaviour can be seen when you get near the target logic it seems the setvelocity command doesn't kill off all the vehicle's momentum and completely set it in the new direction. Some is retained and the vehicle appears to slightly skid. Interesting stuff!

Maybe later this week or weekend I'll work on the next bit which is pitching the plane up on its rear wheels and pushing it into the air before handing over to the AI. Using this script you could actually make *anything* takeoff even a truck assuming it didn't blow up at 180 mph!

Have some fun playing around with the 'runwaylogic' game logic's position in the editor as the plane will always aim dead for it and accelerate no matter what! :D

Important:

I've enjoyed making this so consider it a gift just for you because you asked the question and prompted me to have a great time! EGO is the constant enemy through life and no doubt to many this script will even at this stage seem quite complex. I am quite happy to spend as much time as is needed to show anyone else how to do this and thoroughly explain how it works so don't be afraid to ask - I won't be sitting atop my ivory tower basking in the exclusive rays of my own overblown glory, because if I pursue that attitude my life will turn sh*t, fast, for reasons I can't discuss here.

**Edit

I was incorrect in my statements about the setvelocity command. When I tried this with the player as pilot the plane's motion was perfect right up to the end. With the AI as pilot which is the default loadout on this mission as comes in the download you can see lots of aileron (pilot applied turning attempt) applied on the wings which adds a force which slight pushes the aircraft South as it moves. Seems the disableAI "MOVE" still doesn't really well, disable the AI :)

Edited by chris330
Update.

Share this post


Link to post
Share on other sites

You may want to look at pitch, if I remember right there is a pitch function you can use which is quite good.

I managed to get quite a nice roll out of the C130 using it, I couldn't get any AI aircraft to do a full loop though as it runs into a vector direction problem.

I also used to to dive an aircraft at the runway and then fly at just a meter or two above the ground with mixed results.

Applying pitch while a C130 is taking of at Utes does get the plane off the ground sooner but two much and it will stall out. I did try and give it some velocity but I never felt 100% happy with the out come.

I also tried attaching an invisible jet to the C130 which worked but sometimes gave odd results.

Share this post


Link to post
Share on other sites

Thanks for the reply and the good info it contained ;)

**I've just written a getpitch function and setpitch one too so I might give them a go now with that see if I can get it into the air like you said. I like the idea of simulating of rocket lifting, after watching some youtube vids that thought entered my head too ;)

Edited by chris330

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  

×