Jump to content
Sign in to follow this  
Arctic

Chopper won't land

Recommended Posts

Hello there! This question has been asked countless times, but mine deals more with a script. So I have a chopper named AFlight that moves from airport to the Invisible H pad called LZ.

I have the following code:

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

#EnableAI

AFlight move getpos LZ

@((AFlight distance LZ) < 1)

unassignvehicle a1

unassignvehicle a2

unassignvehicle a3

unassignvehicle a4

unassignvehicle a5

AFlight land "get out"

AFlight flyinheight 120

AFlight move getpos "homeplate"

The only problem is, the chopper simply hovers at the LZ spot! The chopper lands when I use a waypoint, but I want to use a script to get it to land. What's the darn problem?

Share this post


Link to post
Share on other sites

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">AFlight land "get out"

Hmm, have you tried

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

Instead? smile_o.gif .

Share this post


Link to post
Share on other sites

Another possibility is because of that

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">AFlight move getpos LZ

@((AFlight distance LZ) < 1)

isn't the altitude of the helicopter added to the distance to the LZ .

If yes, the distance will never be < 1 , if the helicopter is flying at +/- 30 m of altitude, instead of 1 , put +/- 40 or 50 (or even more, as the helicopter get more altitude when slowing down) this way the other part of the script will be read.

Share this post


Link to post
Share on other sites
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">AFlight land "get out"

Hmm, have you tried

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

Instead? smile_o.gif .

land "get out" works fine. Only difference is that with "get out" the chopper is supposed to hover over the ground (though I find that the chopper usually lands, except sometimes).

Quote[/b] ]isn't the altitude of the helicopter added to the distance to the LZ .

If yes, the distance will never be < 1 , if the helicopter is flying at +/- 30 m of altitude, instead of 1 , put +/- 40 or 50 (or even more, as the helicopter get more altitude when slowing down) this way the other part of the script will be read.

That is indeed the problem.

1: The distance is the actual distance from the chopper to the LZ. So if the chopper flies 50 m above ground, and it actually positions itself perfectly over the LZ, the distance is still 50. So unless the chopper is flying at max 1 m above the ground, it'll never work.

2: If the distance command didn't add altitude, it would still be a problem. Choppers isn't really that accurate. Often they stop short or too long after the LZ. So it's not very likely you'll get it to stop so that check would have worked anyway.

You could check the distance without the altitude easily though.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">@((sqrt(((getpos AFlight select 0) - (getpos LZ select 0))^2 + ((getpos AFlight select 1) - (getpos LZ select 1))^2) < 10)

Something like that...

Share this post


Link to post
Share on other sites

Yea Garcia and Sanctuary were right. Thanks, I never thought that the distance command would only do the x-axis distance! The pythagorean theorem did the trick tounge2.gif

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  

×