Page 1 of 1

[Tutorial] Triggering an object animation through LUA

Posted: Mon Nov 21, 2011 1:15 pm
by DarthD.U.C.K.
its easy to trigger a animation made in zero editor through lua but there is no such command to trigger animations of objects that were created in xsi.
the workaround is pretty easy but i decided to post it nonetheless. you can do really cool things with it, especially in combination with ze-animation, e.g. landing ships with deploying landinggear.

what you do is making an object with a deathanimation that you kill through lua to trigger the animation.
what you need first is a working animationset for the object. you need two animations:
-the idle animation, with the object in the pose before the triggered animation. e.g. the ship flying
-the death animation, the animation that you want to trigger. e.g. the ship with the ladinggear deploying
in the msh.file should have the object in the pose after the triggered animation. e.g. the ship with the landinggear deployed.

here is an example odf for the object:

Code: Select all

[GameObjectClass]       
ClassLabel      =   "animatedbuilding"
GeometryName    =   "ship.msh"

[Properties]        
GeometryName	=   "ship"
DestroyedGeometryName = "ship"
MaxHealth 		= "1000"		//the value doesnt matter

AnimationName   =   "ship"		//the name of the animset
IdleAnimation   =   "flying"	//the first animation
DeathAnimation  =   "landing"	//animation that will be triggered

AINoRepair      = "1"			//necessary, if the ai is able to reach it

HideHealthBar	= "1"			//these two values prevent the player from
IsNotTargetableByPlayer = "1"	//recognizing this as an destroyable object

FoleyFXGroup    = "metal_foley"
now to the lua, under scriptpostload you should add these lines to prevent the object from being killed before you trigger the animation:

Code: Select all

	--ship setup--
	SetProperty("ship", "MaxHealth", 1e+37) --give the object an infinite healthlimit
    SetProperty("ship", "CurHealth", 1e+37)	--and unlimited health
	SetAIDamageThreshold("ship", 0.0) --preventing the ai from damaging it, just to be sure
now all you have to do to play the animation is putting this line in the event that should trigger the animation, like:

Code: Select all

	OnWhatever(
        function(something)
			SetProperty("ship", "CurHealth", "0") --trigger the animation
        end,
        somename
    )
thats all you have to do, if you have trouble with the destroyed model(like animated pieces missing or at 0.0.0), make a seperate model for the destroyed geometry.

i hope this will be helpfull to somebody sometime..

Re: [Tutorial] Triggering an object animation through LUAaaa

Posted: Mon Nov 21, 2011 1:17 pm
by THEWULFMAN
Awesome workaround. I think Firefang and I had toyed with a similar idea, but we never got around to really testing anything. Nice job. :thumbs:

Re: [Tutorial] Triggering an object animation through LUA

Posted: Mon Nov 21, 2011 1:26 pm
by kinetosimpetus
*adds to bookmarks*

Re: [Tutorial] Triggering an object animation through LUA

Posted: Tue Nov 22, 2011 2:39 pm
by naru1305
aha, you figured it out, thx man, it will be verry helpful for me :D
DarthD.U.C.K. wrote:e.g. landing ships with deploying landinggear.
yeah, yeah, my acclamator and coreship anim...