• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Fixed flying height - not relative to terrain

Status
Not open for further replies.
Ok, so maybe this is easy and I'm being dumb again.
I made a flight system. It has a lift function which adjusts
the units flying height based on a variable. Simply:

  • lift action
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Animation - Change Chopper[1] flying height to (Real(Height[1])) at 300.00
However, the chopper flies all crazy going over the mountains
or any terrain variation. I want it stabilized. I want the chopper
to stay at the same level over all types of terrain.
See [VVVV] Choplifter link in my signature if you want to see
the whole system.
What would be really great is it it crashed into the land if it ran
into it or any doodads. Super bonus points for anyone who can
point me in that direction!
 
Level 16
Joined
Dec 15, 2011
Messages
1,423
Hi. Here is something that I think may solve your problem.

CLoc is a location variable that refers to your unit's current loc. The following custom script will give you the value of the terrain's z coordinate.

  • Custom script: set udg_Real = GetLocationZ(udg_CLoc)
Then you set the unit's fly height to be relative to the location's z.

  • Animation - Change Chopper[1] flying height to (ConstantHeight - Real) at 300.00
If Real > ConstantHeight, that means the chopper is going to crash ;)

For destructables, through a method of your own, we will have a destructable variable an then we use the following custom script

  • Custom script: set udg_Real2 = GetDestructableOccluderHeight(udg_Dest)
Same as above, if Real2 > ConstantHeight, the chopper will go all "Mayday! Mayday!"

Oh and btw I am writing these functions free hand so there may be a syntax error or two. Please forgive me if that happens :p
 
Level 13
Joined
Mar 29, 2012
Messages
542
Hi. Here is something that I think may solve your problem.

CLoc is a location variable that refers to your unit's current loc. The following custom script will give you the value of the terrain's z coordinate.

  • Custom script: set udg_Real = GetLocationZ(udg_CLoc)
Then you set the unit's fly height to be relative to the location's z.

  • Animation - Change Chopper[1] flying height to (ConstantHeight - Real) at 300.00
If Real > ConstantHeight, that means the chopper is going to crash ;)

For destructables, through a method of your own, we will have a destructable variable an then we use the following custom script

  • Custom script: set udg_Real2 = GetDestructableOccluderHeight(udg_Dest)
Same as above, if Real2 > ConstantHeight, the chopper will go all "Mayday! Mayday!"

Oh and btw I am writing these functions free hand so there may be a syntax error or two. Please forgive me if that happens :p

Don't worry...You type it perfectly :)
 
Hi. Here is something that I think may solve your problem.

CLoc is a location variable that refers to your unit's current loc. The following custom script will give you the value of the terrain's z coordinate.

  • Custom script: set udg_Real = GetLocationZ(udg_CLoc)
Then you set the unit's fly height to be relative to the location's z.

  • Animation - Change Chopper[1] flying height to (ConstantHeight - Real) at 300.00
If Real > ConstantHeight, that means the chopper is going to crash ;)

For destructables, through a method of your own, we will have a destructable variable an then we use the following custom script

  • Custom script: set udg_Real2 = GetDestructableOccluderHeight(udg_Dest)
Same as above, if Real2 > ConstantHeight, the chopper will go all "Mayday! Mayday!"

Oh and btw I am writing these functions free hand so there may be a syntax error or two. Please forgive me if that happens :p

Ok, I'm doing better now. But the chopper still bounces up and down a little. I was thinking it adjusts itself, so I moved the variables into the same trigger as the animation. That helped a little but it still bounces as it flies. It also seems to be bouncing over doodads (trees). Can't I just set it to a hard Z? What I mean is can't I take the terrain height out of the equation all together?
  • lift action
    • Events
      • Time - Every 0.02 seconds of game time
    • Conditions
    • Actions
      • Set CLoc = (Position of Chopper[1])
      • Custom script: set udg_Real = GetLocationZ(udg_CLoc)
      • Animation - Change Chopper[1] flying height to ((Real(Height[1])) - Real) at 300.00
      • Custom script: call RemoveLocation ( udg_CLoc )
  • Third Person Camera
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Set TempPoint = (Position of Chopper[1])
      • Set TempHeight = (Real(Height[1]))
      • Camera - Pan camera for Player 1 (Red) to TempPoint with height (TempHeight + (250.00 - Real)) above the terrain over 0.40 seconds
      • Camera - Set Player 1 (Red)'s camera Distance to target to 900.00 over 0.40 seconds
      • Camera - Set Player 1 (Red)'s camera Angle of attack to 320.00 over 0.30 seconds
      • Sound - Play helicopter_hovering_01 <gen>
      • Custom script: call RemoveLocation ( udg_TempPoint )


  • Crash
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
      • Real Greater than or equal to (Current flying height of Chopper[1])
      • (Current movement speed of Chopper[1]) Greater than or equal to 10.00
    • Actions
      • Unit - Set life of Chopper[1] to 0.00

  • Lift up
    • Events
      • Player - Player 1 (Red) Presses the Up Arrow key
    • Conditions
    • Actions
      • Trigger - Turn on Lift up count <gen>
  • Lift up count
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
      • Height[1] Less than 1000
    • Actions
      • Set Height[1] = (Height[1] + 5)
 
Last edited:
Level 16
Joined
Dec 15, 2011
Messages
1,423
Ok, I'm a bit of a custom scripting newb. I can fix leaks but thats about it. So... the trigger with Cloc will get the height. Do I create an integer variable called Cloc first?

Ok then, I want the chopper to start on the ground and lift off. So I would "Set Cloc = (whatever the starting height is)" right? Then I replace hieght[1], which is my current variable, with (ConstantHeight - Real)? What are constantheight and real? Are they also integer variables and where did we get them? I also need the chopper to land properly, so a crash would only happen if the chopper's constantheight < real and unit speed > 20. (or something like that). I think you got the solution right, I'm just not quite getting all the details. Thank you x100, for your help. I think you have got me 90% there, but if you could just push me a little further I think we can get it done.

CLoc is a point variable that represents the chopper's current location. You will update it in a periodic trigger.

Constant height is the height that you want the chopper to stay at. Real is the z value of CLoc that I showed you in the custom scripts. Oh and they are both real variables, not integer ones.

I hope this will clear everything out :)
 
See edit ^^ oops - never had that happen before.

I had encountered the same problem, and I am pretty sure it is in this map. I think I set jumping to F2. Feel free to change the terrain to see if it works.

Thats pretty sweet, but I couldn't get much out of it for a lift system. Its a really nice key movement system though. It did que me in a bit though. I showed me to use Real variables rather than integer. If you have more I'd love to see 'em.
 
Last edited:
That's the last full keyboard-controlled map I made... Feel free to do whatever you want with it :D

Thanks! Its actually a really great system, but its a bit advanced for me. I realize that I need a better movement system - one that permits a side-2-side motion. A chopper game is just not complete without it.

I would love to get some help on it if you are interested, otherwise I'll probably have to dig through your map and try to learn how to do what you did. In any case thank you again, and thank you Doomlord! Both of you have been great!
 
Status
Not open for further replies.
Top