wraithseeker
Tired.
If I were to give time and displacement as user inputted variables, which formula should I use to get vi and vf?
I tried to derive formulas from here but to no avail
I tried to derive formulas from here but to no avail
private function Periodic takes nothing returns nothing
local integer i = 0
local Jump d
loop
exitwhen i >= Count
set d = FlyZ<i> // gravity = -981. TIMEOUT = 0.03
set d.vz= d.vz+ 0.5 * d.gravity * TIMEOUT
set d.vi= d.vi+ d.vz *TIMEOUT
call SetUnitFlyHeight(d.target,d.vi,0.0)
if d.vi < 0. or GetWidgetLife(d.target) <= 0.0451 then
call d.destroy()
call d.Code.execute(d.target)
set Count = Count - 1
if Count > 0 then
set FlyZ<i> = FlyZ[Count]
set i = i - 1
else
call PauseTimer(Timer)
endif
endif
set i = i + 1
endloop
endfunction
function Heh takes unit u,real displacement, real time returns nothing
local Jump d
local real velocity = 0.
if IsUnitInGroup(u,HitGroup) then
set d = Jump<u>
set velocity = 2.00*displacement/time - 0.00 // yr formula
set d.vz = d.vz+velocity
else
if Count == 0 then
call TimerStart(Timer,TIMEOUT,true,function Periodic)
endif
set velocity = ((2.00*displacement)- 0.00)/(time*time) // err.. the formula im trying to test.
call BJDebugMsg(R2S(velocity))
set d = Jump.create(u,velocity)
set Jump<u> = d
set FlyZ[Count] = d
set Count = Count + 1
call GroupAddUnit(HitGroup,u)
endif
endfunction</u></u></i></i>
function timer takes nothing returns nothing
//Get data
local MaxHeight = 150
set data.integer = data.integer + 1
call SetUnitFlyHeight(data.unit, ( MaxHeight * 4 * data.integer / TurnOff ) - ( MaxHeight * 4 data.integer * data.integer / TurnOff / TurnOff ), 0)
if data.integer >= TurnOff then //Turn off can be Distance of the 2 points divided by the movement occured of the unit each intervall
//Destroy Timer
endif
endfunction
My bad.If I were to give time and displacement as user inputted variables, which formula should I use to get vi and vf?