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

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Post Reply
Ace_Azzameen_5
Jedi
Jedi
Posts: 1119
Joined: Sat Apr 23, 2005 8:52 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

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

Post 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"
)
User avatar
Fiodis
Master of the Force
Master of the Force
Posts: 4145
Joined: Wed Nov 12, 2008 9:27 pm
Projects :: Rannoch + Tientia + Tools Programming

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

Post by Fiodis »

Heh, a simple solution that lets us slowly animated units. Very nice.
User avatar
Eggman
Master Bounty Hunter
Master Bounty Hunter
Posts: 1516
Joined: Mon Jul 16, 2007 1:30 pm
Projects :: Battlefront Chronicles
Location: Las Vegas

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

Post 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.
Ace_Azzameen_5
Jedi
Jedi
Posts: 1119
Joined: Sat Apr 23, 2005 8:52 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

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

Post 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.
Post Reply