- Joined
- Nov 27, 2007
- Messages
- 85
I have a ball in my map and I need to make its vertical movement smooth.
Currently its height and vertical speed are updated every 0.1 sec.
0.1 sec isn't perfect and it looks rough to the naked eye, especially when vertical speed is high.
It would be logical to simply update the vertical position/speed in 0.01 or 0.05 periodic trigger, yes, but this would require major reconstruction of the map and a lot of testing.
So I was wondering, about other ways to achieve smoothness effect.
For example, what about using an action (a func?) that smoothly changes unit height within passed time-argument.
So my question is - Is there a way to smoothly update unit fly height, like so:
I can rememberr third argument in SetUnitFlyHeight func:
Rate is definitely not "time" argument, but perhaps it can be used somehow to emulate time?
Here's how vertical speed/height are updated in my map:
Currently its height and vertical speed are updated every 0.1 sec.
0.1 sec isn't perfect and it looks rough to the naked eye, especially when vertical speed is high.
It would be logical to simply update the vertical position/speed in 0.01 or 0.05 periodic trigger, yes, but this would require major reconstruction of the map and a lot of testing.
So I was wondering, about other ways to achieve smoothness effect.
For example, what about using an action (a func?) that smoothly changes unit height within passed time-argument.
So my question is - Is there a way to smoothly update unit fly height, like so:
JASS:
function UnitUpdateHeightSmoothly takes unit u, real new_height, real time
I can rememberr third argument in SetUnitFlyHeight func:
JASS:
native SetUnitFlyHeight takes unit whichUnit, real newHeight, real rate returns nothing
Here's how vertical speed/height are updated in my map:
JASS:
function UpdateBallVerticalPositionAndHeight takes nothing returns nothing
real h_ball = GetUnitHeight(udg_Ball)
call SetBallHeight(h_ball + udg_BallVZ) // udg_BallVZ is vertical speed per 0.1 second, so it can be used without a multiplier here
set udg_BallVZ=udg_BallVZ - udg_G // subtract G from vertical speed
endfunction