Mmk.. I have a few lava pits on my map & the lava rises and falls with time. If a unit walks into the lava, they die. I want to show their death by moving the unit to a height just above the lava's surface.
Basically I want to move a unit (before death) to a height between 4 & 8 depending on lava surface height (ie. game time).
The trigger below pushes all the units to a height of 8, never anything else, and I cannot figure out where I went wrong.
========v==============The important part==============v==============
I think a better question is: Why don't you make the height 8 and change the duration to the same as however long it takes the lava to go from the minimum killing height to the maximum height?
That or use a loop and increment the unit's height over time.
Er, wait a minute. You can't change the height of ground units that way. You have to send an actor message to the actor of the unit to change its height, and you have to use an incremental loop to make it gradual. Or morph the unit into a flying/low-flying unit and THEN use the change height action.
@grenegg, i use 4+4*Abs(cos(Elapsed time of timer/2pi/7)) because.. Abs keeps the function always positive, cos makes the function a wave so it goes up and down with time instead of just increasing forever, and elapsed/2pi/7 is just a conversion to scale the function to the lava flow time scale...
@Bash, I can't increment the units height over time because the movement must be instant. The lava does damage over time, but as soon as lava is going to give the killing shot, I want to move the unit just above the lava's surface (which goes from 3 to 7 over 7 seconds, forever) so the unit's death can be visible.
Imagine my height function is just cos(x) & x=elapsed time of Timer.. This SHOULD go from 1 to -1 back and forth... but I'm getting 1 all the time.. Why is my Timer variable giving me 0 always even though I know it's running?
Setting the height to the cosine of a real will not cause the unit to bob up and down forever. It also will not return a random number between 1 and -1 or interpolate between the two randomly (or sequentially.) Cosine is to be used with angles and returns a cosine value, which can be used to determine other things.
Instead, set the unit's height to the height of the lava at the time. You can also run a check to see if the lava is rising, then continually change the height of the unit to match the height of the lava (or just above it) until the lava stops rising.
lol... you just described what I'm already trying to do...
I know trig. I am not trying to make the unit bob up and down forever. I want to set the unit height (one time) to the same height as the lava. It is impossible to check the lava's height directly since I'm using a change in water state trigger for that.
My function is flawless except for the elapsed timer thing... I think I should change the title of this topic to "Timer help" because there is obviously something I am missing when it comes to timers ):
Unless your not having it be lineir, you know exactly how high it is based of of how long its been sense you told it to rise.
Yes, every 7 seconds it goes between 3 & 7. What I meant when I said that was there is no "lava height" variable or "check lava height at region" trigger or w/e...
I'm trying to use a timer variable because it tracks the game time, which is what tracks the lava height.. I'm working around the 'no direct route' problem, but it's not working...
At 60 seconds of elapsed time, the first function returns 7.998
The second function returns 5.57288...
Still doesn't explain why you're returning 0 (or 1?) in the game engine. It could be a problem with setting the duration of the timer to Infinite. Try using a really high number instead, like 99999.
So i tried changing from infinite to a huge number, also tried using duration instead of elapsed time of timer... nada =\
now i just tried random angle to make sure cosine isnt broken... random angle worked the way it should... it gave me random heights within my bounds
aaaaaaaaaaaaahhhhhhhhhhhhhhh, why is the stupid timer giving 0 even though it's running... Or does anyone have another way of tracking game time that won't give 0 when I try to use it with math?
Well, you could just start a loop in an independent thread on map initialization that adds 1 to a real variable every second. Or 0.1 every 0.1 seconds.
Have you tried returning the duration of the timer in a chat message? If the timer returns correctly then the problem is somewhere in your math.
After a bunch of research I found out blizzard fux me over again... 1: they have all their angles in Degrees, not radians.. so this fuk'd my equation over... & 2: I had to set the absolute height of my units to match perfect with the set state ignore terrain trigger... The timer itself wasn't the problem
For anyone wishing to vary a unit's height whether they are in a hole or on flat land with time:
Unit - Turn (Triggering unit) Ignore Terrain Height state On
Unit - Change (Triggering unit) height to (A + (B * (Abs((Cos((90.0 * ((X) / C)))))))) over 0.0 seconds
A = Lowest height for unit to be pushed to
B = Max height above A for unit to be pushed to
X = Variable that you want unit height to vary with. For me it was time, so I set a Timer variable (One shot timer started at melee initialization)
C = Time it takes to reach highest height from lowest height.
Example:
Show a unit as it dies just above lava height. Lava height varies from 3 to 7 over 7 seconds. Base ground height is 8, but there are pits for lava of course.
Unit - Turn (Triggering unit) Ignore Terrain Height state On
Unit - Change (Triggering unit) height to (2.5 + (4.0 * (Abs((Cos((90.0 * ((Elapsed time of GameTime) / 7.0)))))))) over 0.0 seconds
This would place the dying unit just below the lava's surface so you could see part of their body stick above of the lava as they died and watch them burn.
Ty 2 every1 for helping.
edit: & I guess technically you could use this for a jetpack system also with a bit of tweaking.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Mmk.. I have a few lava pits on my map & the lava rises and falls with time. If a unit walks into the lava, they die. I want to show their death by moving the unit to a height just above the lava's surface.
Basically I want to move a unit (before death) to a height between 4 & 8 depending on lava surface height (ie. game time).
The trigger below pushes all the units to a height of 8, never anything else, and I cannot figure out where I went wrong.
========v==============The important part==============v==============
========v==============Full code==============v==============
Oh & the timer is just there to test that the timer wasn't 0 (my initial thought)
Bump, also updated 1st post a bit..
I'm not sure why the "Elapsed time of Timer" is returning 0 and causing my function to always spit out 8.
Explanation/help please
edit: i meant elapsed time, not duration... the duration is set to infinite
Uhhhh I don't get this, why don't you say 4+(4*(duration of timer/time takes to change))
I think a better question is: Why don't you make the height 8 and change the duration to the same as however long it takes the lava to go from the minimum killing height to the maximum height?
That or use a loop and increment the unit's height over time.
Er, wait a minute. You can't change the height of ground units that way. You have to send an actor message to the actor of the unit to change its height, and you have to use an incremental loop to make it gradual. Or morph the unit into a flying/low-flying unit and THEN use the change height action.
@grenegg, i use 4+4*Abs(cos(Elapsed time of timer/2pi/7)) because.. Abs keeps the function always positive, cos makes the function a wave so it goes up and down with time instead of just increasing forever, and elapsed/2pi/7 is just a conversion to scale the function to the lava flow time scale...
@Bash, I can't increment the units height over time because the movement must be instant. The lava does damage over time, but as soon as lava is going to give the killing shot, I want to move the unit just above the lava's surface (which goes from 3 to 7 over 7 seconds, forever) so the unit's death can be visible.
Imagine my height function is just cos(x) & x=elapsed time of Timer.. This SHOULD go from 1 to -1 back and forth... but I'm getting 1 all the time.. Why is my Timer variable giving me 0 always even though I know it's running?
Setting the height to the cosine of a real will not cause the unit to bob up and down forever. It also will not return a random number between 1 and -1 or interpolate between the two randomly (or sequentially.) Cosine is to be used with angles and returns a cosine value, which can be used to determine other things.
My advice: Drop the cosine idea. It won't work. Reference for Sine, Cosine, and Tangent
Instead, set the unit's height to the height of the lava at the time. You can also run a check to see if the lava is rising, then continually change the height of the unit to match the height of the lava (or just above it) until the lava stops rising.
I think that's what you're looking for, anyway.
@BasharTeg: Go
lol... you just described what I'm already trying to do...
I know trig. I am not trying to make the unit bob up and down forever. I want to set the unit height (one time) to the same height as the lava. It is impossible to check the lava's height directly since I'm using a change in water state trigger for that.
Cosine, by definition has a range of y values between -1 and 1. Cosine(0) = 1
http://www.wolframalpha.com/input/?i=%284.0+%2B+%284.0+*+%28Abs%28%28Cos%28%28%28x%29+%2F+%286.2832+%2F+7.0%29%29%29%29%29%29%29%29
is exactly what my function looks like. Check out tha graph.
My function is flawless except for the elapsed timer thing... I think I should change the title of this topic to "Timer help" because there is obviously something I am missing when it comes to timers ):
Unless your not having it be lineir, you know exactly how high it is based of of how long its been sense you told it to rise.
Yes, every 7 seconds it goes between 3 & 7. What I meant when I said that was there is no "lava height" variable or "check lava height at region" trigger or w/e...
I'm trying to use a timer variable because it tracks the game time, which is what tracks the lava height.. I'm working around the 'no direct route' problem, but it's not working...
What does your timer look like? Where do you set the timer, and what is the duration you set it to?
I think your parentheses are off a bit. You want the function:
But what you have is:
At 60 seconds of elapsed time, the first function returns 7.998
The second function returns 5.57288...
Still doesn't explain why you're returning 0 (or 1?) in the game engine. It could be a problem with setting the duration of the timer to Infinite. Try using a really high number instead, like 99999.
So i tried changing from infinite to a huge number, also tried using duration instead of elapsed time of timer... nada =\
now i just tried random angle to make sure cosine isnt broken... random angle worked the way it should... it gave me random heights within my bounds
aaaaaaaaaaaaahhhhhhhhhhhhhhh, why is the stupid timer giving 0 even though it's running... Or does anyone have another way of tracking game time that won't give 0 when I try to use it with math?
Well, you could just start a loop in an independent thread on map initialization that adds 1 to a real variable every second. Or 0.1 every 0.1 seconds.
Have you tried returning the duration of the timer in a chat message? If the timer returns correctly then the problem is somewhere in your math.
@BasharTeg: Go
I was thinking of doing the +1 as a last resort... And the variable returns 0
After a bunch of research I found out blizzard fux me over again... 1: they have all their angles in Degrees, not radians.. so this fuk'd my equation over... & 2: I had to set the absolute height of my units to match perfect with the set state ignore terrain trigger... The timer itself wasn't the problem
For anyone wishing to vary a unit's height whether they are in a hole or on flat land with time:
Unit - Turn (Triggering unit) Ignore Terrain Height state On
Unit - Change (Triggering unit) height to (A + (B * (Abs((Cos((90.0 * ((X) / C)))))))) over 0.0 seconds
A = Lowest height for unit to be pushed to
B = Max height above A for unit to be pushed to
X = Variable that you want unit height to vary with. For me it was time, so I set a Timer variable (One shot timer started at melee initialization)
C = Time it takes to reach highest height from lowest height.
Example:
Show a unit as it dies just above lava height. Lava height varies from 3 to 7 over 7 seconds. Base ground height is 8, but there are pits for lava of course.
Unit - Turn (Triggering unit) Ignore Terrain Height state On
Unit - Change (Triggering unit) height to (2.5 + (4.0 * (Abs((Cos((90.0 * ((Elapsed time of GameTime) / 7.0)))))))) over 0.0 seconds
This would place the dying unit just below the lava's surface so you could see part of their body stick above of the lava as they died and watch them burn.
Ty 2 every1 for helping.
edit: & I guess technically you could use this for a jetpack system also with a bit of tweaking.