Some ranged weapons fire more than one projectile at once. A shotgun is a good example of this. In this recipe, we will learn how to set up a projectile weapon to fire multiple projectiles at once.
Start by making sure the ShapeBaseImageData Datablock
instance of your projectile weapon has its class
property set to WeaponImage
. This gives the weapon access to Torque 3D's standard weapon handling methods.
The next step is to add the projectileNum
dynamic property to Datablock
of your weapon and give it a value greater than 1
. This property represents the number of projectiles fired per shot.
When a
ShapeBaseImageData
weapon is fired its onFire()
method is called. The WeaponImage
namespace already handles most cases so it is a convenient class to have our ShapeBaseImageData
inherit from.
The
WeaponImage::onFire()
method supports the idea of multiple projectiles per shot, which is set up using the dynamic
projectileNum...