Game Toolkit for Unity
Setting up the bomb pickup and bomb explosion.
In this tutorial we’ll create the schematics to pick up bomb crates and exploding bombs.
First, we’ll set up the bomb pickup schematic. The bomb crate works like the health crate – it will float down from the sky and land on the ground. When the player enters the trigger machine playing the schematic, he will get a defined number of bombs (object variable).
Open the Makinom editor, navigate to Schematics and create a new schematic. Change the following settings.
Add Node > Game > Player > Is Player
First, we’ll check if the starting object is the player.
Add Node > Machine > Start Tagged Machine
In case it’s not the player, we try landing the crate.
This node is connected to the Failed slot of the Is Player node.
Click on Add Tag to add a starting tag.
Add Node > Value > Variable > Change Variables
We’ll use this node to add a bomb to the player’s bomb counter.
This node is connected to the Success slot of the Is Player node.
Click on Add Variable to add a variable change.
Add Node > Audio > Audio > Play Sound At Point
We’ll use this node to play a taunt sound of the player.
Finally, we’ll destroy the crate’s game object from the root (in case it’s still hanging on the parachute).
That’s it for the schematic – click on Save Schematic and save it as BombPickup in Assets/Schematics/.
Next, we’ll create a schematic that will be used by the bomb’s explosion schematic to push enemies away from the bomb when it explodes.
Create a new schematic and change the following settings.
Add Node > Game Object > Rigidbody > Rigidbody Add Force
We can do this in one node by directly getting the direction and multiplying it by the force we want to apply.
That’s it for the schematic – click on Save Schematic and save it as BombForce in Assets/Schematics/.
Next, we’ll set up the bomb’s explosion schematic. The explosion will kill all enemies within a defined radius (local start variable).
We need a machine start variable (radius), 1 actor and 1 prefab.
Click on Add Start Variable to add a new variable.
We’ll use an explosion particle effect that’s already placed in the scene as actor. Actors are game objects that are already present in the scene – unline prefabs, we don’t need to spawn them.
Click on Add Actor to add an actor.
We’ll spawn a circle shaped prefab to show the explosion radius.
Click on Add Prefab Resource to add a prefab resource.
Add Node > Game Object > Raycast > Check Shape
We’ll use this node to get all enemies within a circle around the bomb.
The Origin defines where the center of the circle is – it’ll be the bomb’s position.
The Radius defines the size of the explosion.
The Layer Mask defines which layers we’ll check for objects.
We’ll use Filter Game Objects to only use game objects tagged Enemy.
Click on Add Object Check to add a filter.
We need to use the found game objects in the next steps, so we’ll set them to the local selected data hitObject.
Add Node > Machine > Start Machine
We’ll use this node to push away the enemies with the BombForce schematic.
This node is connected to the Success slot of the Check Shape node (i.e. we’ve found enemies in the explosion radius).
We’ll use this node to kill the enemies by starting their tagged machine with the die tag.
We’ll use this node to play an explosion sound.
This node is connected to the Next slot of the previous node and the Failed slot of the Check Shape node (i.e. we didn’t find enemies, but the bomb still explodes).
Add Node > Movement > Movement > Change Position
We’ll use this node to place the explosion particle actor at the bomb’s position.
Add Node > Game Object > Component > Emit Particles
We’ll use this node to start the explosion particle effect.
Add Node > Game Object > Prefab > Spawn Prefab
We’ll use this node to spawn the circle prefab.
Add Node > Game Object > Prefab > Destroy Prefab
We’ll use this node to destroy the circle prefab after 0.1 seconds.
Add Node > Machine > Start Global Machine
We’ll use this node to start the global machine handling the pickup spawning – we’ll set it up later, so just select the first global machine that we’ll use later. Exploding the bomb will result in the next pickup being spawned after some time.
Add Node > Game Object > Game Object > Destroy Object
Finally, we’ll destroy the bomb – since we’ll also use this schematic on the bomb crate (which can explode when hit by a rocket), we’ll destroy the bomb from the root, in case the crate is still attached to the parachute.
And that’s it for the schematic – click on Save Schematic and save it as BombExplosion in Assets/Schematics/.
The next tutorial will handle laying bombs and bomb prefabs.
© 2015 Gaming is Love e.U.
Disclosure: This site may contain affiliate links, which means I may receive a commission if you click a link and purchase something that I have recommended. While clicking these links won’t cost you any money, they will help me fund my development projects while recommending great assets!