Learn how to make Games: Unity (Part 8) - Zapping those enemy ships with Unity 3D and Playmaker!
Hi I'm Jerry from Bliz Studio LLC. Nothing is more satisfying than creating some bullets in your game and getting input from the player to fire those in your game. Here is the process to do that in Unity3D and Playmaker as the visual scripting tool. How to Make a Video Game With Unity3D and Playm
Part 8 makes the bullets matter: enemy ships now explode when hit, complete with a particle burst, an explosion sound, and camera shake. Along the way it builds something with long-term value — a reusable camera-shake FSM that any other system in the game can call by name.
Step 1 — A reusable camera-shake service
On the main camera, add an FSM named Camera Shake (naming FSMs matters — objects can carry several). It has an idle start state plus three states: shake small, shake medium, shake big. Create matching events and promote each to a global transition, so external FSMs can trigger them. Each state runs a Shake Position action with Loop Don't Finish off: 0.1 units for 0.1 seconds (small), 0.3 for 0.3 (medium), 0.5 for the big one. Set it up once, call it from anywhere, forever.
Step 2 — Detect the bullet hit
Make an explosion sound in Bfxr (mash the Explosion preset until one sounds right) and export it as enemy explosion. In the enemy's FSM, add a trigger check for the bullet tag (tag the bullet prefab if you haven't) sending a blow up enemy event to a new state. First test: silence — because the bullet prefab has a Rigidbody 2D but no collider, and two objects can't detect each other without colliders on both. Add a Box Collider 2D with Is Trigger to the bullet and the Play Audio action fires correctly.
Step 3 — Call the shake from a prefab
A prefab can't hold a scene reference to the camera, so the blow-up state first runs Get Main Camera, storing the result in a variable, then Send Event By Name targeting that variable's FSM with the event shake medium (copy-paste event names to dodge typos). A great bug followed: the player ship went flying off-screen, because the rocket's old iTween shake and this new camera shake ran simultaneously and fought over the transform. The fix is consolidation — delete the rocket's own shake action and have the firing state call shake small on the camera FSM the same way. One shake authority, no conflicts.
Step 4 — The explosion burst
Add a particle system to the enemy: duration about 1.5 seconds, looping off, lifetime Random Between Two Constants 0.3-1, size 0.2-0.8, start color Random Between Two Colors from yellow to red (giving oranges in between). The explosion shape comes from Emission: rate over time 0, plus a single Burst of 100 particles in one cycle. Color Over Lifetime fades alpha to zero only in the last third, so the fireball stays solid then dissipates. Two refinements from testing: set simulation space to World so the explosion stays put instead of riding the still-falling ship, and leave the particle object deactivated — activating a game object auto-plays its particle system, which is exactly how the FSM triggers it.
Step 5 — Hide, then destroy
The dead ship must vanish instantly while its explosion lingers, so drag the enemy's Sprite Renderer into the state and use Set Property on the sprite field with nothing assigned — an empty sprite renders as invisible. The full blow-up sequence is now: play audio, get main camera, send shake, activate particles, blank the sprite, then a FINISHED transition into the existing Destroy Self state to remove the object for good. Next episode: a score UI that counts the kills.





