HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Projectile Motion: Let It Drop!

10-10-2008, 10:15 PM#1
Flame_Phoenix
Hi guys, I am making a bomber spell. The spell is much like others I guess, but I want it to drop bombs in a realistic way.
I know this involves phisics and maths, but I would really like to do it.
So, I decided to make a search on google for maths, but I found nothing that could help me .... therefore I am quite blind in doing this ...

Can some one help me please ?
Here is a video I found, that explains what I want: imagine the hand dropping the ball is a bomber dropping a bomb.
http://ali.apple.com/ali_sites/nhli/exhibits/1000786/

I am kinda tired, maybe I searched with bad keywords, I don't know, but I know now I am going to sleep.
If some one could help me, I would ofc give +rep and credits on spell.

Btw, here are more links I found, but none tells me the math of the stuff, but I don't seem to quite understand it now:
http://www.glenbrook.k12.il.us/gbssc...ctors/hlp.html
http://www.ac.wwu.edu/~vawter/Physic...lesMotion.html

EDIT EDIT:
Ok guys, now I know that if my plane travels at a 900 (warcraft) speed, my bombs will also travel at 900 speed. My problem here is how I change their hight correctly.
First I need a good number for Warcraft gravity (-9.8 is not good at all) and second I don't see how I will attach this to the variable "t" which is the current time ...
I know we can use SetUnitFightHeight(..) but I don't have practice on using it, can some one help ?
10-10-2008, 10:31 PM#2
the-thingy
Not really sure what you're looking for (is it the math, or the code, or what?), but perhaps MaDOS, SEE, Particle System (I think that's what it's called) or Vector System (for the math, not really sure what the Vector System includes) might be some good places to start
10-10-2008, 11:38 PM#3
Captain Griffen
The bomb's horizontal initial speed will be the same as the planes. This will be constant, unless reduced by air resistance. The vertical speed will start as zero, and have a negative acceleration of g, possibly reduced by air resistance (which is a non-linear function of speed).
10-10-2008, 11:44 PM#4
Bobo_The_Kodo
I usually use about -50 *Interval gravity

The height is much easier to be calculated from 0 using GetLocationZ(x,y) + Height, and the set as SetUnitFlyHeight( u, z-GetLocationZ(x,y), 0 )
10-11-2008, 01:10 PM#5
Flame_Phoenix
Quote:
The bomb's horizontal initial speed will be the same as the planes. This will be constant, unless reduced by air resistance. The vertical speed will start as zero, and have a negative acceleration of g, possibly reduced by air resistance (which is a non-linear function of speed).
I know the horizontal speed is constant, as I said before my problem is the height of the thingy ... and no, I am not considering air resistance, since there is no wind in warcraft, that would be quite silly xD

So, we would have something like this:
Collapse JASS:
function DropBomb takes nothing returns nothing
    local unit bomb = CreateUnit(........) //we create a bomb at 300 height
    call SetUnitFlyHeight( bomb, GetUnitZ(bomb)-GetLocationZ(x,y) * timer, 0 )
endfunction
Please correct me, I really believe this is wrong =S
10-11-2008, 02:34 PM#6
Bobo_The_Kodo
I use something like these for handler functions:

Collapse JASS:
    globals
        location ZLoc = Location( 0, 0 )
    endglobals

    function GetPointZ takes real x, real y returns real
        call MoveLocation( ZLoc, x, y )
        return GetLocationZ( ZLoc )
    endfunction
    
    function GetUnitZ takes unit u returns real
        call MoveLocation( ZLoc, GetUnitX( u ), GetUnitY( u ) )
        return GetUnitFlyHeight( u ) + GetLocationZ( ZLoc ) )
    endfunction
    
    function SetUnitZ takes unit u, real z returns nothing
        call MoveLocation( ZLoc, GetUnitX( u ), GetUnitY( u ) )
        call SetUnitFlyHeight( u, z - GetLocationZ( ZLoc ), 0 )
    endfunction

Then on a timer expire:

Collapse JASS:

    set <zvel> = <zvel> - gravity*Interval
    call SetUnitZ( <unit>, GetUnitZ( <unit> ) - <zvel> )


assuming you have a struct attached or something to keep zvelocity and the unit...
10-11-2008, 03:00 PM#7
Flame_Phoenix
Mmm, all that region thing will make the scrip kinda inefficient right ?
Guys, I am trying to add this to the rest of my spell, should I start a new thread ?
10-11-2008, 03:02 PM#8
Anitarf
Quote:
Originally Posted by Flame_Phoenix
I know the horizontal speed is constant, as I said before my problem is the height of the thingy ... and no, I am not considering air resistance, since there is no wind in warcraft, that would be quite silly xD
Wind has nothing to do with this.
10-11-2008, 03:05 PM#9
Flame_Phoenix
Quote:
Wind has nothing to do with this.
Wind can affect the motion of projectiles, and yes, there is no air resistance in wc3 either ... I kinda explained myself bad xD
Anyway, I will soon post spell code here again (?) ... hope some one can help me besides Anitarf.
10-11-2008, 03:21 PM#10
Bobo_The_Kodo
I just showed you all you need to know for it, its really kinda simple
10-11-2008, 04:21 PM#11
Flame_Phoenix
Mmm, I don't think that is MUI ... for me things that work are not enough, because I know later Anitarf is going to harras me for efficiency lol xD
I will make changes and post code soon here !
10-11-2008, 04:33 PM#12
Bobo_The_Kodo
wtf how wouldn't that be MUI?>??!?!?
10-11-2008, 04:40 PM#13
Flame_Phoenix
Quote:
wtf how wouldn't that be MUI?>??!?!?
Because I only have 1 location (global) and I have several units at the same time using it =S
10-11-2008, 05:05 PM#14
Here-b-Trollz
I don't think anyone has pointed this out...

GetLocationZ() on cliffs can act weird. With MoveLocation(), it returns inaccurately (this can cause a sort of sliding downward U shape when going over cliffs). It only returns correctly with Location(). I don't know if anyone has realized this, but from my testing this appears to be the case.

edit:

Collapse JASS:
function GetZ takes real x, real y returns real
    local location l=Location(x,y)
    local real z=GetLocationZ(l)
    call RemoveLocation(l)
    set l=null
    return z
endfunction

function GetZ takes real x, real y returns real
    call MoveLocation(L,x,y)
    return GetLocationZ(L)
endfunction

The first one, while slower, is more accurate. This is of course, just to my testings. I could be doing something wrong.
10-11-2008, 05:06 PM#15
the-thingy
But all the units won't be handled at EXACTLY the same time, so it'll move the location, GetLocationZ, GetUnitZ, do the actions for the a particular unit, THEN it'll move onto the next unit, repeating the same process. MUI with globals isn't really a worry unless you're adding in waits and/or using them in conjunction with timers