Setting up the enemy ship’s machines.
After creating the schematics for moving the enemy ship, it’s time to set up the machine components on the prefab. However, first we’ll add the machine components to the enemy’s weapon bolt.
Select the Bolt Enemy prefab (found at Assets/Tutorial Resources/Prefabs/). We’ll add a Mover schematic and a Hit schematic like we did with the player’s bolt.
The Mover schematic will be added using an auto machine component. The schematic will set the game object’s velocity when it’s added to the scene.
Add an auto machine component to the Bolt Enemy prefab (e.g. using the component menu: Makinom > Machines > Auto Machine). Change the following settings.
The Machine Start Variable we’ve set up in the schematic is automatically added here, so all we need to do is adjust it to our needs. Make sure the variable is enabled.
We’ll add the Hit schematic using a trigger machine component. Add a trigger machine component (e.g. using the component menu: Makinom > Machines > Trigger Machine).
Change the following settings.
The Machine Start Variable we’ve set up in the schematic is automatically added here, the default value is all we need. Make sure the variable is enabled.
That’s it for the Enemy Bolt prefab. Since we added the component directly on the prefab, we don’t need to apply the changes.
Select the Enemy Ship prefab (found at Assets/Tutorial Resources/Prefabs/), we’ll add multiple components to it.
First, we’ll set up the object variables of the enemy ship. Add an object variable component to the prefabs (e.g. using the component menu: Makinom > Scenes > Object Variables).
Click on Add Variable to add an object variable.
Copy the variable and change the following settings.
That’s it for the object variables.
The enemy ship is moved using a rigidbody component, i.e. we’ll need to Fixed Update for the physics updates.
Add a tick machine component to the prefab (e.g. using the component menu: Makinom > Machines > Tick Machine). Change the following settings.
The Machine Start Variables we’ve set up in the schematic are automatically added here with their default values – since the default values are already what we need, we don’t have more to do here. Make sure all variables are enabled.
We’ll add the enemy maneuver schematic using a repeating auto machine component. This will restart the machine after it finished executing.
Add an auto machine component to the prefab (e.g. using the component menu: Makinom > Machines > Auto Machine) and change the following settings.
The Destroy schematic handles the destruction of a game object, spawning a particle effect prefab and playing and audio clip. The tagged machine component we’ll use for that will be started by the Hit schematic using the tag destroy.
Add a tagged machine component to the prefab (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.
First, we’ll override Prefab 0 used by the schematic.
Click on Add Prefab to add a prefab that will be used.
Now, we’ll override Audio Clip 0 used by the schematic.
Click on Add Audio Clip to add an audio clip that will be used.
The Hit schematic reduces the health of game objects that are hit by the enemy ship. If the health drops to 0, it will start the destroy tagged machine.
The hit mechanic will use a trigger, add a trigger component to the asteroid prefabs (e.g. using the component menu: Makinom > Machines > Trigger Machine).
Finally, we’ll add the FireShot schematic using a repeating auto machine. This will fire the enemy’s bolts according to the enemy’s fire rate.
Expand the Resource Overrides to change the used prefab and audio clip.
That’s it for the Enemy Ship prefab. Since we added the component directly on the prefab, we don’t need to apply the changes.
To get the enemy ship into the game, we’ll need to add it to the GameController schematic. Open the schematic, either through the Makinom editor, by double clicking on the asset file in the project view (can be found at Assets/Schematics/) or through the Edit Schematic button in the asset file’s inspector.
Select the Settings node of the schematic and change the following settings.
Click on Add Prefab in the Hazards prefab (Prefab 0).
And that’s it – click on Save Schematic to save the changes.
Click on Play to test the game. The enemy waves will now also contain enemy ships. The enemy will fly evasive maneuvers randomly and fire bolts at the player.
The final tutorial will be short and simple – moving the background.