HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

ParabolaZ2

07-26-2009, 12:55 PM#1
wraithseeker
Collapse JASS:
   set nH = ParabolaZ(.ho+.SL,.EL+.ho,.maxheightK,.distance,.movedistance)
            call SetUnitFlyHeight(.target, nH-.SL,0)
// .ho is the inital height of the unit before the knockback
//.sl is starting location height
// .el is ending location height
Why does a knocked back air unit not go back to his originial flying height when the knockback ends?

For example I just tested a green drake that has a initial height of 280 and it ended up around 256.
07-26-2009, 01:27 PM#2
Anitarf
Aren't you passing too many arguments to the ParabolaZ function?
07-26-2009, 01:34 PM#3
wraithseeker
Collapse JASS:
library ParabolicMovement2

function ParabolaZ2 takes real y0, real y1, real h, real d, real x returns real
  local real A = (2*(y0+y1)-4*h)/(d*d)
  local real B = (y1-y0-A*d*d)/d
  return A*x*x + B*x + y0
endfunction

endlibrary

There is another verison which takes into initial z position and end z position.
07-26-2009, 01:47 PM#4
Anitarf
Yeah, but you're not calling that function, you're calling the original.
Quote:
Originally Posted by wraithseeker
Collapse JASS:
   set nH = ParabolaZ(.ho+.SL,.EL+.ho,.maxheightK,.distance,.movedistance)
            call SetUnitFlyHeight(.target, nH-.SL,0)
// .ho is the inital height of the unit before the knockback
//.sl is starting location height
// .el is ending location height
07-26-2009, 01:59 PM#5
wraithseeker
I renamed it to ParabolaZ as I had no ParabolaZ2 in my script.
07-26-2009, 02:11 PM#6
Anitarf
*sigh*

Anyway, your problem is this:
Collapse JASS:
            call SetUnitFlyHeight(.target, nH-.SL,0)
You're supposed to subtract the terrain z at the unit's current position, not at the start position.
07-26-2009, 02:31 PM#7
wraithseeker
Let me test it but I read his script and it said

Quote:
This function will return the absolute height and therefore this value should be the height you must set to the unit in the function SetUnitFlyHeight()-y0.

And y0 is initial z point.

EDIT: Still not the correct height.
07-26-2009, 07:35 PM#8
Anitarf
Well, are you sure that the last time you update it, .movedistance equals .distance?
07-27-2009, 06:25 AM#9
wraithseeker
Yes.
07-27-2009, 02:43 PM#10
Anitarf
Quote:
Originally Posted by wraithseeker
Yes.
Sure? Not greater than or equal to, but exactly equal to? If you're moving it on a periodic timer, that might not be the case; also, the final location might not be at precisely the target spot. Have you tried using it on flat terrain?
07-28-2009, 06:45 AM#11
wraithseeker
Flat terrain is a litttle off still.

I am moving it on a periodic timer.

The final location should be at the target spot as i used kinematics. Even if it didn't, tried on flat ground and also failed.

movedistance seems to be a little off and so is the unit's height

For example,

.movedistance = 1170
.distance = 1150
initial height = 280
end height = 290

It's just that off.

Calculation for .movedistance is .movedistance = .movedistance + .velocity.getLength() * TIME
07-30-2009, 02:02 PM#12
wraithseeker
bump
07-30-2009, 02:16 PM#13
Anitarf
Well, if movedistance is off at the end of the movement, you can't expect the height to be correct. The function will give you the correct endheight only if x equals d.