Exploding Bullets

This script is a bit more complex than the last. The script is attached to a bullet which also has its own child controller/emitter nested under it. After a set time, the parent bullet is destroyed and triggers the child controller to produce a shot, creating the appearance of an exploding effect.


You’ll notice that this script [A] inherits from IRePoolable, which allows the parent bullet to be repooled. [B] Start() is overriden to set up connections to the renderer as well as the child controller. [C] An EventTimerDo event is used to set when the trigger for the child controller occurs. [D] The RePool routine called by [E] RePoolOrDestroy() has custom procedures to reset the state of a couple of custom fields.


The resulting behavior produces a bullet which appears to explode after a set time.