• 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] Choppy movement when throwing a unit up in the air

Status
Not open for further replies.
Level 5
Joined
May 20, 2008
Messages
138
Hi! I am making a spell that throws the target straight up in the air, until it slows down, starts falling again and finally lands on the ground. I use two triggers, one that launches at the spell cast and starts a repeating timer, and another that launches each time the timer expires. So, the second trigger works like a loop, and handles the calculations of how high the unit needs to be moved each 0.3 seconds with the Animation - Change Unit Height action using the s = ut + (at^2)/2 formula.

The problem I am having is that though the unit moves through the correct points in it's motion path, it moves very choppily between them. Instead of smoothly moving the next distance as soon as the first is finished, it pauses for a split second at each point in the course. It looks very ugly and I am wondering if there is some problem with the Animation - Change Unit Height action that prevets it from being used to create smooth movements using heights changed in increments like I am doing?

And also, what would you do to get my trigger to move the unit up and back down again like I want it to without the choppiness?

  • Akilzon boss Gust of Wind spell cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • AkilzonBoss_incombat Equal to True
      • (Ability being cast) Equal to (Boss2) Gust of Wind
      • AkilzonBoss_storm_inprogress Equal to False
    • Actions
      • Set AkilzonBoss_GoW_target = (Target unit of ability being cast)
      • Unit - Add Crow Form to AkilzonBoss_GoW_target
      • Unit - Remove Crow Form from AkilzonBoss_GoW_target
      • Unit - Pause AkilzonBoss_GoW_target
      • -------- ------------- --------
      • -------- ------------- --------
      • -------- ------------- --------
      • -------- ------------- --------
      • -------- ------------- --------
      • Set AkilzonBoss_GoW_time = 0.00
      • Set AkilzonBoss_GoW_speedconstant = 300.00
      • Set AkilzonBoss_GoW_height = AkilzonBoss_GoW_speedconstant
      • Animation - Change AkilzonBoss_GoW_target flying height to AkilzonBoss_GoW_height at AkilzonBoss_GoW_height
      • -------- ------------- --------
      • -------- ------------- --------
      • -------- ------------- --------
      • Countdown Timer - Pause AkilzonBoss_GoW_timer
      • Countdown Timer - Start AkilzonBoss_GoW_timer as a Repeating timer that will expire in 0.30 seconds
      • -------- ------------- --------
      • -------- ------------- --------
      • -------- ------------- --------
      • -------- ------------- --------
      • -------- ------------- --------
The loop:

  • Akilzon boss Gust of Wind height change
    • Events
      • Time - AkilzonBoss_GoW_timer expires
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • AkilzonBoss_GoW_time Not equal to 6.00
          • AkilzonBoss_GoW_height Greater than 0.00
        • Then - Actions
          • Set AkilzonBoss_GoW_time = (AkilzonBoss_GoW_time + 0.30)
          • Set AkilzonBoss_GoW_height = (AkilzonBoss_GoW_speedconstant + ((AkilzonBoss_GoW_speedconstant x AkilzonBoss_GoW_time) + ((-100.00 x (AkilzonBoss_GoW_time x AkilzonBoss_GoW_time)) / 2.00)))
          • Animation - Change AkilzonBoss_GoW_target flying height to AkilzonBoss_GoW_height at AkilzonBoss_GoW_height
        • Else - Actions
          • Countdown Timer - Pause AkilzonBoss_GoW_timer
          • Set AkilzonBoss_GoW_height = 0.00
          • Animation - Change AkilzonBoss_GoW_target flying height to AkilzonBoss_GoW_height at 100
          • Unit - Unpause AkilzonBoss_GoW_target
 
Level 9
Joined
May 27, 2006
Messages
498
First of all use a lesser interval, 0.3 (if i understood correctly that this is the interval) is way too high, set it to something like 0.04, it will move very smoothly

As to height formula, i would recommend using this:
JASS:
function GetParabolaZ takes real x, real d, real h, returns real
    return 4 * h * x (d -x) / (d * d)
endfunction
d - max distance
x - current distance
h - max height
Taken from Dark Gandalfs' tutorial http://www.hiveworkshop.com/forums/tutorial-submission-283/about-movement-172309/. Unless you want a different jump-like effect, but i don't know any other parabolic function...
 
Level 5
Joined
May 20, 2008
Messages
138
Thanks a lot for your reply! Yes you understood it correctly, I will try to lower the timer to 0.03 instead and see how it goes.

I'm not sure what you mean by parabolic path. Anyway, luckily my movement simply goes straight up and straight down, in a vertical movement. So the formula i use is
s = ut + (a*(t^2))/2 where
s = the distance it needs to move each interval
u = the initial distance moved per interval before deacceleration/acceleration = AkilzonBoss_GoW_speedconstant
a = an acceleration/deacceleration constant that I have set to -100
t = Time expired = current value of AkilzonBoss_GoW_time in the loop
seems to work prefectly fine to handle the math
 
Level 5
Joined
May 20, 2008
Messages
138
He meant that you can make the "up and fall" stuff with a parabola, just as the time goes, increase value x and it will go up and after a time, down.

Btw the formula should be credited to Spec and Moyack but ofc everybody can figure it out if they know their math right.

Ah I see

Code:
function GetParabolaZ takes real x, real d, real h, returns real
    return 4 * h * x (d -x) / (d * d)
endfunction



Does that translate into this:
Code:
 (4 * h * x * (d - x)) / (d * d)

according to the tutorial:

Variables:

* d: distance between starting and end point
* x: distance between starting point and the missile
* h: maximal height


Did I get it right? How would that work? Since my unit moves 0 distance and only upwards to max height h I would get a number divided with 0 (d*d = 0*0), which isn't possible. I don't see how I would use that function in a looping trigger :s Explanations are much appreciated!
 
Level 9
Joined
May 27, 2006
Messages
498
Yeah. you've got it right, there is a multiplication sign. No idea why it's missed tho, i copy'n'pasted it directly from Dark Gandalfs' tutorial, probably there was a typo

And yes, you've figured those variables out correctly. In your case d and x will both be equal to 0, which is a problem, but a very minor one, since we can just set d to some low value, like 1.0. There will be no noticeable difference in-game, and you will be able to make a use of the formula.
In fact, you don't even have to move your unit, so it really doesn't matter whether numbers you use are as low as 1 or as big as 10000.

Does that translate into this:
Code:
 (4 * h * x * (d - x)) / (d * d)
Yes

I don't see how I would use that function in a looping trigger :s
Like that:
  • Events
    • Time - my_timer expires (0.04 interval)
  • Conditions
  • Actions
    • Set x = x + 0.04 || [max_dist * interval = 1.0*0.04 = 0.04]
    • Set current_height = (4 * h * x * (d - x)) / d*d || [4 * 300 * x * (1-x)]
    • Animation - Set my_unit's flying height to current_height at 0.00
 
Last edited:
Level 5
Joined
May 20, 2008
Messages
138
Yeah. you've got it right, there is a multiplication sign. No idea why it's missed tho, i copy'n'pasted it directly from Dark Gandalfs' tutorial, probably there was a typo

And yes, you've figured those variables out correctly. In your case d and x will both be equal to 0, which is a problem, but a very minor one, since we can just set d to some low value, like 1.0. There will be no noticeable difference in-game, and you will be able to make a use of the formula.
In fact, you don't even have to move your unit, so it really doesn't matter whether numbers you use are as low as 1 or as big as 10000.

Allright thanks a lot! I also got my spell working out fine now :) Do you think there would be any advantage using that formula over the one I am using though?
 
Level 9
Joined
May 27, 2006
Messages
498
There are no advantages at all, it was just me misunderstanding you, and thus overcomplicating a simple problem... I would say, stay by your formula, as far as i can tell it makes your unit slow down a little while in mid-air. The formula i've posted doesn't do that, it's more like a quick jump.
 
Level 5
Joined
May 20, 2008
Messages
138
There are no advantages at all, it was just me misunderstanding you, and thus overcomplicating a simple problem... I would say, stay by your formula, as far as i can tell it makes your unit slow down a little while in mid-air. The formula i've posted doesn't do that, it's more like a quick jump.

Allright thanks for the clarification :) Yes, it makes my unit do the same movement as say a tennis ball would do if you threw it vertically up into the air and let it fall down again. First time I've taken home something useful from the math lessons it feels like lol :p
 
Status
Not open for further replies.
Top