Page 1 of 1

How To: Animate Objects W/O ZE .ANM, Incl. Vehicles, Units

Posted: Fri Feb 05, 2010 4:38 pm
by Ace_Azzameen_5
I've worked out a simple way to animate things in SWBF2 without ZeroEditor ANM files.
It may be more difficult, but is useful if you've hit the keyframe cap.
Also, in the case of simulating the jump to lightspeed, it is easier as the LUA code allows for the incremental increase of speed that would take too many keyframes in ZE.
It would take a lot of work, but you could also make some very smooth cornering animations, as I plan to do.

The other problem this solves [somewhat] that of 'Animating Vehicles', where people want to have the Script sort of drive a vehicle a player is in or whatever.

Posted below is a recursive[sic?] script that repeatedly moves an object to a new matrix, using CreateMatrix, that is a given distance from the last, until the given number of frames is exceeded (integer variable a). The result is a smooth animation that is physics compatible, so long as the FPS is high enough. The FPS is controlled by a Timer, with a length of 1/60th a second, which restarts itself.
The below code produces a smooth acceleration, done by increasing the translation(movement) value by 1/60th of itself each frame, which means it~doubles in distance every second, resulting in a speed increase.
If wanted, the division variable can be made smaller (faster acceleration, but less smooth)
or the timer value can be made smaller (smoother, faster animation as a whole)


Videos

Animation of Static Object


Animating a Vehicle in SWBF2

Code: Select all

XTranslate = 0.01 -- smoothness factor
ObjectToAnimate = "cis_prop_mtt"
CreateTimer("FrameRate")
SetTimerValue("FrameRate", 0.016666666666666667)
StartTimer("FrameRate")

Matrix = GetEntityMatrix(ObjectToAnimate)

OnTimerElapse(
function()
Matrix = CreateMatrix(0, 0, 0, 0, XTranslate, 0, 0, Matrix)	
SetEntityMatrix(ObjectToAnimate, Matrix)

SetTimerValue("FrameRate", 0.016666666666666667)
StartTimer("FrameRate")

XTranslate = XTranslate + XTranslate/60  -- Increase the XTranslate by 1/60th 
end,
"FrameRate"
)

Re: How To: Animate Objects W/O ZE .ANM, Incl. Vehicles, Units

Posted: Fri Feb 05, 2010 4:47 pm
by Fiodis
Heh, a simple solution that lets us slowly animated units. Very nice.

Re: How To: Animate Objects W/O ZE .ANM, Incl. Vehicles, Units

Posted: Fri Feb 05, 2010 4:58 pm
by Eggman
Also, in the case of simulating the jump to lightspeed, it is easier as the LUA code allows for the incremental increase of speed that would take too many keyframes in ZE.
It would take a lot of work, but you could also make some very smooth cornering animations, as I plan to do.
Both of those can be done in ZE's animation mode through spline-type transitions and local translation.

This could be very useful though for the other reasons you listed here and the issue with the editor crashing constantly in animation mode for some people.

Re: How To: Animate Objects W/O ZE .ANM, Incl. Vehicles, Units

Posted: Fri Feb 05, 2010 11:28 pm
by Ace_Azzameen_5
Yeah, and there also the possibility of random animations, small variations on the course of objects.
I might use this for a repeatedly landing Gunship I have deploying troops.