• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Defining the height

Status
Not open for further replies.
Level 10
Joined
Sep 21, 2007
Messages
517
How do we define the height of a bullet in a linear movement? so the height changes realistically with the movement? I know the funcs to get Z and x and y angle, rect and such, so u can just explain it mathematically, dont need to know what functions are needed. Thank you for your time. Il make sure to give you credit for the math help, a web page simply explaining the *correct* math behind it is alright too.
 
I don't understand what you mean. You it stays at the same height, no matter what terrain is beneath it? Basically you subtract the terrain height from whatever height you want the unit to be at, and add the starting terrain height. Say you want it to stay at height 100, every time you move it you do something like:

JASS:
//assume the height of the terrain is in a variable called "currentTerrainHeight"
//and the terrain height it started at is in variable "startTerrainHeight"
//and the dummy unit is in variable "dummy"
call SetUnitFlyHeight(dummy, 100. + startTerrainHeight - currentTerrainHeight, 0.)
 
Level 10
Joined
Sep 21, 2007
Messages
517
o no man, not what i mean. like the height change in Elim tourny, how bullets go in a linear line and with some fixed height change depending on the location z of each loc. On another hand, how about if this is a constant dynamic changing factor. Like the start terrain height - beginning terrain height + original height of missile, adding that height difference? Hmm you do know what im saying right bro?

so how about height difference*timeupdate + unit current flying height? but yea it changes depending on terrain height, but i think this works for missiles going up or down. any input on it bro?
 
Level 10
Joined
Sep 21, 2007
Messages
517
Not a parabola my friend, for that is an arc. I am looking for a linear movement with correct height change, resembling a correct bullets movement. ill do the collision myself so its fairly alright ^^ Thanks for putting up links and everything guys ) appreciate it
edit~~ i need to +rep you guys, you did attempt to help afterall (goes for pharaoh you and basee ^^)

omg... cant give to krics.. need to spread; how nice lawl
 
Level 22
Joined
Dec 31, 2006
Messages
2,216
I think this is what you're looking for:
JASS:
globals
    constant hashtable h = InitHashtable()
endglobals

function Loop takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local unit u = LoadUnitHandle(h, GetHandleId(t), 1)
    local real x = GetUnitX(u) + 4.
    local real y = GetUnitY(u) + 4.
    local location l = Location(x, y)
    local real z = LoadReal(h, GetHandleId(t), 2)-GetLocationZ(l)
    call SetUnitPosition(u, x, y)
    call SetUnitFlyHeight(u, z, 0.)
    set z = z + GetLocationZ(l)
    call SaveReal(h, GetHandleId(t), 2, z)
    set t = null
    set u = null
endfunction

function Example takes unit u returns nothing
    local real x = GetUnitX(u)
    local real y = GetUnitY(u)
    local location l = Location(x, y)
    local real z = GetUnitFlyHeight(u)+GetLocationZ(l)
    local timer t = CreateTimer()
    call UnitAddAbility(u, 'Amrf')
    call UnitRemoveAbility(u, 'Amrf')
    call SaveUnitHandle(h, GetHandleId(t), 1, u)
    call SaveReal(h, GetHandleId(t), 2, z)
    call TimerStart(t, 0.03, true, function Loop)
    call RemoveLocation(l)
    set l = null
    set t = null
endfunction
 
Level 10
Joined
Sep 21, 2007
Messages
517
hmm... this makes it move like a bullet in a linear movement? well the z height atleast? cus i see you subtracted it by the locations height which means the bullet will always have go downward and not upwards? tho i think its really interesting physics u applied there tho thanks! ;P
 
Level 10
Joined
Sep 21, 2007
Messages
517
Thanks ) il try it bro, i think i +reped you already tho ))
il use intercept movement, i only need the height, so il try it )
----> still gotta strengthen my knowledge of OOP... meh, just started jass but what the hell, gotta try doing that oop shit, thanks bro :p
<i think il try storing in dat array or something... if i dont get syntax errors lawl>
 
Level 6
Joined
Oct 31, 2008
Messages
229
Except of that i think a very good way to make a bullet dummy in linear movement incline/decline, is to make a dummy that fires the bullet (and has infinite range) and another that has variable flying height which will be hited.
 
Level 16
Joined
Oct 12, 2008
Messages
1,570
Think about it. The fixed height you want is let's say 300. The terrain height is at place one 100. Then you set it's flying height to (300-100). Now a second later, the terrain height is 200. Then you set it's flying height to (300-200).

Fixed Height = Terrain Height + Unit Fly Height.

The only thing you can set about a unit in this aspect is it's flying height. So we got the simple equation:
Unit Fly Height = Fixed Height - Terrain Height.
 
Level 10
Joined
Sep 21, 2007
Messages
517
the thing is, the math behind it, what it is, not making it in line with terrain, just making a realistic bullet movement like in elim ) hopefully il try devils way and it works

yes yixx, u prurposed that after Devil did, but il still give you rep )

only problem with that is that it does not spawn from from some height, and spawns the bullet above the unit itself :]

problem is it neds to be dynamic movemnt, not static movement, like height increases in time or decreases in time :]
------------------------------
diablo, man wait, i thik urs can work really well, but i dont think it increases or decreases in time. should i just set a specific rate in the rate parameter? i think that may work, but the rate must be based on dist, atleast i think so >_<

btw i think the speed should be modifiyable, not set at a specified real like you did there, the 100 * angles, you mean 100 is the speed in that case and the speedx + speedy is the movement ?
 
Level 10
Joined
Nov 10, 2004
Messages
351
I'm not sure i understand what you're saying, but i'll try:

When you say rate parameter, do you mean the "100" in the formula? If yes, then i think i know what you're saying. The "rate" parameter is the amount of distance you want to move the bullet.

If you're moving the bullet with a timer, you set the rate to how far you want it to move every second, and multiply it with the period of the timer.

Edit: Yeah, it's exactly like you say in the edit. The 100 is the speed(was just a random number) and the speedx, speedy and speedz are the movement.
 
Level 10
Joined
Sep 21, 2007
Messages
517
, il use the *time, thanks alot bro, il try it out, btw how does it feel starting mapmaking for so long and still going at it? nvm about the parameter rate, i meant by it the rate of the conversion of the units height, like set unit fly height unit u to height 300, rate 300 (which is 1 second, you prob know that tho) so thats what i meant ) its ok now il just use that speed and * it ^^

kk il try it tommorow, since i just started jass like what... yesterday, but! i saw alot of jass scripts, so now i gotta focus on learning the OOP bullshit ;p thanks
 
Level 11
Joined
Apr 29, 2007
Messages
826
If i understand you right, you want your bullets to move in a three dimensional direction, like they do in elimination tournament. If yes, then this should solve your problem:

JASS:
  local real xspeed = 100*Cos(Angle)*Cos(ZAngle)
  local real yspeed = 100*Sin(Angle)*Cos(ZAngle)
  local real zspeed = 100*Sin(ZAngle)

So, I assume the 100 are the actual flying height. But still, how does one get the ZAngle? (might be a dumb question - I suck at maths and physics :/)
 
Status
Not open for further replies.
Top