HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Aiming Equation?

12-09-2007, 03:49 PM#1
Tiku
Basically i made a bullet system, just like in elimination tourny, the only problem is, how do i get the bullet to fly downward towards the aiming spot:
What i have so far is:

Collapse JASS:
local real FH = GetHandleReal(t, "FH")
    local real UHA = GetTerrianHeightAfterUnit(bullet, PointX, PointY, 30.0)
    local real PH = GetTerrianHeightPoint(PointX, PointY)

and the GetTerrianHeightPoint GetTerrianHeightAfterUnit are just custom made functions to get the heights

"FH" Stands for the starting height, (Unit shooting bullets current height+additional for the bullet is the air)
"UHA" Stands for the New Units height, like the height that is in front of it, that way i can modify it to stay in a straight line, and not follow the terrian z.
"PH" Stands for the height that the player targeted to shoot at.

so basically im trying to make it so the bullet moves up or down, depending on the PH's z, but i cant really find a way...

I tried:
  • (FH-UHA)-(FH-PH)
  • (FH-UHA)-(FH-UHA-PH)
because FH-UHA gives the height to make it straight.. so i thouugh of getting the difference between FH and PH then subtracting that from the newheight that makes the bullet straight, yet it still doesnt quite work, the bullet dies when it collides into a cliff or mountain anyway. im not sure what the equation is... if anyone can help me out, it'll be appreciated :D
12-09-2007, 04:26 PM#2
Ammorth
you are going to have to find the distance between the 2 points and then add a part of your height difference, depending on how far it is. The height difference would be final height - initial height. You will get a negative value for aiming down, and a positive value for aiming up.
12-09-2007, 05:06 PM#3
Tiku
thanks ammorth :D
but im still having a few problems...

call SetUnitFlyHeight(bullet, distbe+FH-PH, 0.0)
distbe is the distance between points, and FH is the Init height, PH is the point's height, yet the bullet is like 4x higher than its suppose to be, and i dont really see it flying downward... :/