Page 1 of 9

Flying Unit Question

Posted: Mon Mar 21, 2011 4:06 pm
by EqualiseR
I'm currently working on a map where each player has an airplane, and you control this airplane with arrow keys. The airplane itself functions properly as far as steering goes and what not, however I'm running into a problem where when the airplane flies over an area with increased terrain, the airplane automatically adjusts its height accordingly.

Note: The airplane uses a sliding trigger.

Is there a way to make it so no matter how high the terrain is, the airplane will maintain a height that only the player can change? So like if there's a massive mountain in front of the airplane, the airplane will not automatically fly over it, but stop in front of it (at which point I will make a trigger that kills the plane if it is not high enough)

I made a trigger that checks the terrain height at the position of the airplane, and then deducts that from the flying height, however that does not seem to be working. - I uploaded the map as well, just incase you would like to look at it yourself.

Thank you,
~EqualiseR

Re: Flying Unit Question

Posted: Mon Mar 21, 2011 4:20 pm
by 3ICE
Multiply it by 32/64/128 before adding. I don't know which one is the right constant, but it's got to be one of those.

Re: Flying Unit Question

Posted: Mon Mar 21, 2011 4:24 pm
by EqualiseR
What exactly would I be multiplying and then adding?

Re: Flying Unit Question

Posted: Mon Mar 21, 2011 4:25 pm
by 3ICE
I just found t_all GetLocationZ(point). Subtract that from your flying height and it will work as expected.

Re: Flying Unit Question

Posted: Mon Mar 21, 2011 4:29 pm
by EqualiseR
I already had that. Here's the trigger.

Maintain Flying Height Events Time - Every 0.05 seconds of game time Conditions Actions Set TempPoint = (Position of J-10 0000 <gen>) Custom script: set udg_TempReal = GetLocationZ(udg_TempPoint) Animation - Change J-10 0000 <gen> flying height to ((Real(Red_MaintainFlyingHeight_integ)) - TempReal) at 0.00 Custom script: call RemoveLocation(udg_TempPoint)
the variable 'Red_MaintainFlyingHeight_integ' is an integer variable that follows the flying height only the player controls when a player presses the up / down arrow key, and not when the game adjusts it, this prevents the 'every 0.05 seconds' event from deducting "TempReal" every 0.05 seconds.

Any other ways to go about doing this?

~EqualiseR

Re: Flying Unit Question

Posted: Mon Mar 21, 2011 4:39 pm
by 3ICE
That's what I have always used. And it worked.

By the way why are you using SetCameraTargetControllerNoZForPlayer()?
The camera should follow the airplane on the Z axis too.

Re: Flying Unit Question

Posted: Mon Mar 21, 2011 4:44 pm
by EqualiseR
Can you please edit the map accordingly then? because before I added the "Red_MaintainFlyingHeight" variable, it would just constantly deduct the terrain height from the flying height ever 0.05 seconds, resulting in the flying height always being 0.

And as far as the other questions go, If I recall that was me locking the camera to the airplane for 3 players (Just for beta, so red/blue/teal can follow red's view until I add in more jets)

Thank you,
EqualiseR

Re: Flying Unit Question

Posted: Mon Mar 21, 2011 4:51 pm
by 3ICE
I think I found the problem.
Your default flying height is 100. The first level of cliff is 128. So the plane should crash into all cliffs.
Try it with default flying height at 1000. The plane will stay level.

I thought units could have negative fly height...

EDIT:
EqualiseR wrote:If I recall that was me locking the camera to the airplane for 3 players (Just for beta, so red/blue/teal can follow red's view until I add in more jets)
But what about the "NoZ" part of the function name? Isn't there a "WithZ" version? The camera should follow the airplane in the air, not on the ground.

EDIT2: You should study how the [trigger] tag works. I already fixed one of your posts from where you can reverse-engineer it.

EDIT3: I'm off to bed, big day tomorrow. (I won't get much sleep between 11 pm - 5 am...)

Re: Flying Unit Question

Posted: Mon Mar 21, 2011 4:55 pm
by EqualiseR
Well, when I said my flying height would stay at 0, it could've been negative. I didn't really pay attention.

And on a different note, my flying height in the object editor is by default set to 300. And 3 seconds into the game it gets changed to 100. I can change those if need be, but then still what would I put for the trigger? Would I keep the trigger I'm currently using?

Re: Flying Unit Question

Posted: Mon Mar 21, 2011 4:57 pm
by 3ICE
Keep the trigger, it works fine.

EDIT: Hope you didn't miss my edits.

EDIT2: 1333rd post! 4 more to 1337-ness.

EDIT3: Recounted my posts and it turns out I deleted like 200 but the counter didn't update. So I am not close to 1337 posts yet.