Game Development Community

Object Explosion

by Ali Akhavan · in Torque Developer Network · 07/22/2009 (4:37 am) · 1 replies

Hi,
I am using TGEA 1.8.0
I Want to load Barrel DTS model on game
------> I need to know how write a script , When player weapon fire to this Barrel , this Barrel play
Explosion animation <--------------

Thanks

About the author


#1
07/22/2009 (9:56 am)
Kaboom

You would need to give it Namespace::damage(), Namespace::onDamage() methods. Other useful functions would be Namespace::onEnabled(), Namespace::onDisabled(), and Namespace::onDestroyed().

Inside the damage() function is where you applyDamage()

Inside the onDamage() function you would compare damage states thought getDamageLevel().
  • If damage is greater than the objects destroyedLevel then set it as destroyed (maxDamage).
  • If damage is greater than the objects disabledLevel then set it as disabled.
  • Otherwise assume it is healthy and enabled.
  • Inside this bit of logic you can trigger the appropriate animation triggers, or even swap the model out, to indicate that it is being damaged.

    Your object will need to be setup correctly with the various damageLevel fields in it's datablocks and you will need to have these damage methods in order to cause damage to the object. If you object has an explosion field defined, once it reaches the maxDamage level it will be "destroyed" and "explode".

    Kaboom