Jump to content
Sign in to follow this  
LBpilot1

setting helicopter height

Recommended Posts

AI piloting a chopper, for him to be at a set altitude and stay there.

please be simple i'm new to this if you cant already tell.

Share this post


Link to post
Share on other sites
AI piloting a chopper, for him to be at a set altitude and stay there.

please be simple i'm new to this if you cant already tell.

In the choppers init line (while in the editor double-click on the chopper itself - it will bring up properties and at the bottom of that window is the 'init' line to type stuff into) type

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this flyinheight 20

Best practice is to not use 'this' but to replace 'this' with the name of your chopper. The 'name' field can be found in the same place as the init line, only at the top right.

You have to play with the height '20' to make sure it doesn't run into anything. Typically 35-50 is a safe distance. If you know the route from A to B, then you can adjust it lower.

Share this post


Link to post
Share on other sites

thanks, but is there anyway to get it above 50 Alt.

It doesn't work past 50

Share this post


Link to post
Share on other sites

It doesn´t work in the init above 50 m´s.

Copy this code into the init of your helos or aircrafts:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this setpos [ getPos this select 0, getPos this select 1, 200]

The number at the end defines the height. In this case the helo will start at a height of 200m´s.

Alternatively you can directly change the height of the waypoint but I don´t have the code in my head for that right now.

Maybe a m_search.gif

can bring you some results.

Share this post


Link to post
Share on other sites

I need it to stay at 200 Alt

that just puts it there and it falls back to 50.

Ive search and nothing came up.

Share this post


Link to post
Share on other sites

Just tested and it works with the following line in the init of helo:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this setpos [ getPos this select 0, getPos this select 1, 200]; this flyinheight 200

Helo will be spawned at 200 and keep the height. But be aware that waypoints have their own Z (height) default setting, so if you want to have it really work you have to use setwppos with a 3D array to alter the height of the waypoints. The Biki says that setwppos only accepts 2D coordinates but that´s not true for Arma.

Another approach would be to use GameLogics instead of regular waypoints. Place a GameLogic where you want to have your first waypoint, name it way1 and in it´s init use this code:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this setpos [ getPos this select 0, getPos this select 1, 200];

This will take the virtual waypoint up to a height of 200 m´s

Now in your init of the helo use this code:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this setpos [ getPos this select 0, getPos this select 1, 200]; this flyinheight 200; h1 doMove getpos way1

This will send the helo (name h1) to the virtual waypoint at once. If you want to have more waypoints (fake GameLogic waypoints) place a trigger around the gamelogic have it activated by the helo and in it´s OnActivation use a code like:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">h1 doMove getpos way2

This will send the helo to the Gamelogic way2 once the helo is near way1 (first virtual waypoint).

Share this post


Link to post
Share on other sites

Very strange Lbpilot, but this flyinheight works good for me. I either put it into the chopper's init line or if I need it to change altitude several times in fliegh (f.e. approach low, but then go high for paradrop, than go low again) I just name a chopper (f.e. Helo) and put into waypoints On Activation

Helo flyinheight 50

or

Helo flyinheight 200

It works.

Share this post


Link to post
Share on other sites

Well after some frustratingly mixed results, and Wacky AI making things up as they go.. Today I set up some tests to find out what was and wasn't working.

Lined up a row of choppers and gave each of them FlyInHeight instructions.. Both on init and in waypoints.

Found that 2 out of 5 choppers nearly followed instructions, 3 out of 5 did their own thing and 1 of them did as requested.

Each chopper was named, and I tried several combinations. I even tried giving them all the same instructions.. Mixed results. huh.gif And I got all sorts of anomalies. Some choppers would get to a waypoint and just fly in circles.. banghead.gif Others would do it perfectly.

Am I missing something really key to the process here? I've read all the relevant topics on here and see so many conflicting reports and advice..

Share this post


Link to post
Share on other sites

There are several scripts out that should be helping you with your intentions.

Check out Mando Heliroute

or other ones posted in Adons&Mods.

I guess there was at least one more that gave you perfect control over helos, but I don´t remember the name right now.

Edit:

A quick search came up with Improved helo AI thread

aswell.

Share this post


Link to post
Share on other sites

I think the issue is that this setflyinheight 200 works but at its first or next waypoint it gets reset. Just add helos name setflyinheight 200 to each WP in the onact field.

Share this post


Link to post
Share on other sites

Don't think that will work, since the waypoint it's looking for will never become true; helo is flying around its waypoint at 200m but will never find it because the waypoint is located at 100m or something. I've had a lot of issues with helos at altitude.

Similarly, I've had triggers not detecting helos when they flew too high (even low altitudes if trigger was small enough). Not because of the helo, but I think the triggers height is a function of its x and y size.

Finding a way of moving the waypoint to it's correct height so that it would become true, would seem to me a better method.

Maybe use a BIG random placement size on the waypoint would give something? Sometimes it flyes over, sometimes it get stuck in a neverending searchloop.

Share this post


Link to post
Share on other sites

Thanks for the suggestion Balschoiw, I will look into that.

Guys, I found that when I gave the choppers a flyinheight 200 or 300 in the first waypoint, they would do that, if I left subsequent waypoints alone, the choppers would follow them correctly, but if I gave subsequent waypoints the same flyinheight value as the first one, thats when they would circle the waypoint a random number of times. I think the AI has a mind of its own lol.

Anyway I am off to play with these improved AI flight addons. smile_o.gif

Share this post


Link to post
Share on other sites

The chopper isn't circling randomly. Its an unfortunate out come of how the behaviour was set by BIS. When you set the flyinheight in a waypoint the chopper wont move to the next one till it has reached the set height.

Thats why if it doesn't have to take off you should set the height so it will fly.

Unfortunatly choppers dont flollow WPs well at all. They pause at the next one and the distance to satisfy the WP from the center of the WP is just too far and they never go where you want them to.

You get much better results just scripting the WPs for choppers.

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  

×