Setting up the enemy machines.
In this tutorial we’ll set up the enemy game objects. We’ll add the schematics we created in the previous tutorial using different machines.
The setup for all 3 enemies (Zombunny, ZomBear and Hellephant) is the same (except for minimal differences). The following component setup can be repeated for all enemy prefabs, or you can just copy the components and paste them on the other enemies.
The enemy prefabs can be found at Assets/Tutorial Resources/Prefabs/. We’ll add the components directly to the prefabs.
First, we’ll set up the object variables of the enemies. Add an object variable component to the prefabs (e.g. using the component menu: Makinom > Scenes > Object Variables). Change the following settings.
Click on Add Variable to add an object variable.
Copy the variable and change the following settings.
That’s it for the object variables.
Next, we’ll add the EnemyMovement schematic using a tick machine.
Add the component to the enemy prefabs (e.g. using the component menu: Makinom > Machines > Tick Machine). Change the following settings.
The enemy’s attack will be started while the player is within the enemy’s trigger.
Add a trigger machine component to the enemy prefabs (e.g. using the component menu: Makinom > Machines > Trigger Machine). Change the following settings.
The attack should only start if the enemy’s and player’s health is above 0 using our template.
Click on Add Condition, we’ll set up the variable conditions here.
In the added Condition 0, we’ll set up our variable condition.
Click on Add Variable.
Copy the added variable condition and change the following settings.
The Machine Start Variables we’ve set up in the schematic are automatically added here with their default values, so all we need to do is adjust them to our needs. Make sure both variables are enabled.
Now, we’ll add the TakeDamage schematic using a tagged machine that will be stared by the tag damage.
Add a tagged machine component to the enemy prefabs (e.g. using the component menu: Makinom > Machines > Tagged Machine). Change the following settings.
Click on Add Starting Tag to add a tag that can start this machine.
Expand the Resource Overrides to change the used audio clip.
Click on Add Audio Clip to add an audio clip that will be used.
Finally, we’ll add the EnemyDeath schematic using a tagged machine started by the tag death.
And that’s it for now. Since we added the components directly on the prefabs, we don’t need to apply the changes.
If you want to test your enemies, just drag them into the scene and click on Play. The enemis will move toward the player, if you shoot them, they’ll die once their health is gone. They aren’t yet able to damage the player, since we didn’t add the TakeDamage schematic to the player yet – we’ll do this later.
The next tutorial will handle UI setup.
© 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!