| 09-13-2008, 01:38 PM | #1 |
If I have a 2 points, and a certain speed, how would I calculate the correct z speed then deduct that much from the xy speed. What i'm saying, is i want the distance travelled per Interval to be the same while including the z dimension, this is what i have so far; EDIT: nvm i got it.. JASS:
public function CreateToUnit takes unit origin, string unitid, real x, real y, real z, real radius, real scale, real speed, unit target returns Missile
local real tx = GetUnitX( target )
local real ty = GetUnitY( target )
local real tz = GetUnitFlyHeight( target ) + GetPointZ(tx,ty)
local real z2 = z + GetPointZ( x, y )
local real a = Atan2( ty - y, tx - x )
local real d2 = ( tx - x ) * ( tx - x ) + ( ty - y ) * ( ty - y ) + ( tz - z2 ) * ( tz - z2 )
local real t = d2 / (speed * speed)
local Missile dat = Create( origin, unitid, x, y, z, a * RADTODEG, radius, scale )
call AddZVel( dat, (tz-z2)/t*Interval )
call AddXVel( dat, (tx-x)/t*Interval )
call AddYVel( dat, (ty-y)/t*Interval )
call AdjustTilt( dat, true )
call UnitCollision( dat, true )
//call TerrainCollision( dat, true )
return dat
endfunction
|
