In the previous chapter, we completed the basics of gameplay by allowing the player to shoot bullets and defeat enemies.
In this chapter, we’ll take it further and make the project into something that can actually be played as a game.
What’s Missing to Make It a Game?
In the current version, the player can move and enemies exist, but several elements are still missing.
The stage is too small, so we need to expand it.
The player has a damage reaction but cannot actually be defeated. We also can’t see how much HP the player has left, so we need to make that visible.
Finally, there is no goal to the game. Ideally, we would include a boss battle, but for now we’ll keep it simple: defeating 5 enemies will clear the game.
First, let’s extend the stage by painting more tiles. Since the stage will become larger, the player will eventually move outside the camera’s current range, so we’ll also need to make sure the camera follows the player.
Paint More Tiles
The tiles were created using the Base (TileMapLayer) node, so let’s use this node to expand the stage.
Switch to the stage1 scene tab.
In the Scene window, select the Base (TileMapLayer) node.
Camera following in ACTION GAME MAKER is controlled using a system called Target ID. Do you remember when we created the player and added the CameraTargetSettings node? That node has a property called Target ID.
The camera node, ZoomCamera2D, also has a Target ID property. When both the camera and a game object share the same Target ID, the camera is designed to follow that object automatically.
Let’s configure the Target ID for both the ZoomCamera2D and the player’s CameraTargetSettings.
Set the Target ID for InitialCamera (ZoomCamera2D)
In the Stage1 scene tab, select the InitialCamera (ZoomCamera2D) node.
Add a “Death” Effect to the Player: Creating Particles
Just like the enemy, the player should also be defeated when their HP reaches 0. Since there isn’t a frame that looks suitable for a death animation, let’s use particles to create a visual effect.
What Are Particles?
Particles are essentially tiny images scattered in large numbers to create an effect. Think of something like confetti—it’s easier to imagine. With particles, you can freely adjust the appearance of each “piece” and how they move.
In Godot Engine, this is typically done with nodes like GPUParticle2D or CPUParticle2D.
In ACTION GAME MAKER, particles are handled with the ParticleObject node.
The ParticleObject comes with more than 20 particle templates you can use right away.
Create a Particle Object
Creating a particle object is exactly the same as creating a game object.
You should now see particles emitting in the scene view, creating a fireworks effect.
Finally, right-click the [Unsaved](*) tab and save the scene as deathparticle.tscn.
When the player’s HP reaches 0, they should stop moving and emit the “Death Particle” effect.
It makes sense to connect this state from AnyState, but there’s one problem:
Currently, as shown below, the player transitions to the TakeDamage state whenever they collide with an enemy attack, regardless of their state.
Since there’s no animation that perfectly fits, we’ll reuse the Damage animation. However, to make it visually distinct, we’ll also use a Filter effect so it’s clear the player is defeated.
Open the Player scene.
Switch the editor from 2D to Script.
In the upper area near the Take Damage state, right-click and Add State.
Right now, getting knocked out in a single hit is too harsh, so let’s increase the player’s HP.
But if the player has more HP, we’ll also need a way to display how much remains. For that, we’ll create an HP Bar.
In ACTION GAME MAKER, you can display gauges using the SimpleGauge or ImageGauge nodes. For this tutorial, we’ll use SimpleGauge.
Since the camera now moves with the player, placing the HP Bar in the same layer as the player would cause it to move out of view. For always-visible elements like HP Bars, you should use the UI layer.
About the UI Layer
You may recall from earlier that ACTION GAME MAKER layers are structured as follows. The UI layer and the Screen Effect layer are special layers not affected by the camera.
This means that anything placed in the UI layer will always remain visible, making it perfect for the HP Bar. The Screen Effect layer, on the other hand, is reserved for special effects triggered by actions, so we’ll use the UI layer here.
Set the Player’s HP and Max HP to 10
Select the BaseSettings node of the player.
In the Inspector, change both HP and Max HP values from 1 to 10.
In the Max Value Variable field, it may default to object_id. Change this to max_hp. This tells the gauge to use the player’s maximum HP as its maximum value.
Gauge not visible: Make sure the SimpleGauge is a child of the UI layer and positioned inside the blue boundary.
HP starts low: Double-check that the Player’s HP is set to 10 in BaseSettings.
HP instantly drops to 0 even with Max HP: Confirm that Max HP is set to 10 in BaseSettings and that the SimpleGauge’s Max Value Variable is correctly set to max_hp.
You may have noticed during test play that when the player falls into a pit, they just keep falling forever. Let’s fix this by making the player “defeated” when falling into a pit.
The solution is to limit the camera’s movement range so it doesn’t chase infinitely downward, and then set the player to enter the “Death” state when leaving the camera’s range.
Restrict the Movement Range of InitialCamera (ZoomCamera2D)
This ensures the camera will only move 500 pixels below the red origin line.
Run a test play.
If set correctly, the camera will still follow the player horizontally and upward, but will stop following downward past a certain point.
Troubleshooting
Camera shows nothing:
The tiles may be offset from the origin (the intersection of the red and green axes). Try adjusting the camera’s bottom limit to values like 1000 or 2000 until it aligns properly.
Add Fall Defeat to the Player’s Visual Script
Since the “Death” state already exists, we only need to add a new condition to the existing link: “OffScreen.”
Switch to the Player scene and change the editor view to Script.
Run a test play and fall into a pit.
If set correctly, when the player falls out of the camera’s range, the fireworks particle effect should play, signaling defeat.
Troubleshooting
Fall defeat doesn’t trigger:
Check the conditions on the AnyState → Death link. Make sure they read: HP = 0 OR OffScreen.
Thinking About “Clear the Game by Defeating 5 Enemies”: Handling Variables
We’ll need some way to count down from the number 5. Each time an enemy is defeated, this number should decrease, and when it reaches 0, the game should trigger a clear event. To achieve this, we’ll use something called a variable.
What Is a Variable?
A variable is like a container that stores a value. For example, the player’s HP (health) we worked with earlier is actually a variable. When the player is hit by an enemy attack, the value inside the HP container decreases by 1.
In ACTION GAME MAKER, there are two main ways to define variables:
Using the VariableSettings node on an object.
Using the project-wide Project Variables database.
The HP we used earlier is an example of the first type.
The Difference Between Object Variables and Project Variables
Object Variables (VariableSettings): Variables tied to a specific object. If the object is removed, the variable disappears as well.
Project Variables: Global variables that can be accessed anywhere in the project. They remain available as long as the project is running, and are useful for things like saved data.
In practice:
HP, Attack Power, Jump Force → Best handled as Object Variables.
High Score, Coin Count, Lives → Best handled as Project Variables, since they persist across multiple stages and should be shared across the whole game.
Which Variable Should Track “Remaining Enemies”?
Technically, either type would work. However, since multiple objects (the enemies) will interact with this number, we’ll use a Project Variable.
So the flow will be:
When an enemy enters its “Vanish” state → Decrease the “Remaining Enemies” count by 1.
When “Remaining Enemies” reaches 0 → Trigger the game clear sequence.
How to Implement the Clear Sequence
We’ll create a special game object dedicated to handling the kill count. This object will be placed in the UI layer so it is always visible. Like the HP bar, it will display the number of defeated enemies so the player knows how many are left to clear.
The steps will be:
Create the Project Variable “Remaining Enemies”
Add an action to the enemy’s “Vanish” state that decreases the Kill Count.
Create a Clear Event Object in the UI layer that monitors “Remaining Enemies” and triggers the clear sequence when it reaches 0.
In ACTION GAME MAKER, you modify variables using the Change Property action.
Since you can perform the basic arithmetic operations (add, subtract, multiply, divide), we can implement our logic as: Remaining Enemies –= 1.
Open the enemy scene tab and switch the editor view to Script.
Select the Vanish state and click + Add Executable Action.
There are five fields to set—double-check each one.
With this action, the project variable Remaining Enemies will be decreased by 1.
Finally, reorder the execution actions. Actions run from top to bottom, so if Vanish Self executes before Change Property, the variable won’t be updated.
Drag the hamburger (three-line) icon next to Change Property and move it to the top so Change Property runs first.
In programming, -= is a shorthand operator meaning:
new_value = previous_value - 1
It both subtracts and assigns the result back to the variable in one step.
If you used only - (minus) without the =, it would not specify where to store the result, so the variable wouldn’t actually change.
We’ll make a UI object to manage the Remaining Enemies variable.
This object will display the current value of “Remaining Enemies” and trigger a clear sequence when the value reaches 0. For clarity, we’ll show the enemy’s icon (via Sprite2D) with the Remaining Enemies variable displayed next to it using an action. For the enemy icon, we can simply reuse the existing enemy sprite image.
Switch the editor view to 2D.
Open a new scene tab, and for the root node select GameObject.
Set Object Name to RemainingEnemiesManager, choose Template: UI, and Type: Empty, then click Create.
From the FileSystem, drag enemy.png (the sprite used by the enemy) into the empty space just to the left of the origin (where the red and green axes intersect) in the editor view.
A Sprite2D named Enemy will be added automatically. In Godot, when you drop an image file directly into the editor viewport, it auto-creates a Sprite2D node and assigns the texture for you.
Note: About placement in the “DisplayText” action
This action creates a text box of the specified size centered on the reference point, then displays the specified text (variable) inside it for the duration you choose.
When the reference point is “This object’s center,” it means the origin (the point where the red and green axes intersect).
In this setup, you’re creating an 80×80 px text box centered on the origin, aligning the text to the center, and setting the display duration to unlimited.
Test the “Count” Display
Let’s place it in the scene and test. Because we want it always visible, we’ll put it in the UI layer.
Switch to the stage1 scene tab and change the editor to 2D.
Select the SimpleGauge node under UI (CanvasLayer).
Neither icon nor number appears:
Ensure the object is a child of the UI layer and placed within the blue frame (UI display region).
Icon appears but number doesn’t:
In the Remaining Enemies Manager object, confirm the icon is positioned near the origin, and double-check the DisplayText action settings in the Count state.
Number doesn’t change when enemies are defeated:
In the enemy object’s Vanish state, verify the execution order is Change Property first, then Remove Self.
Next, let’s build the clear sequence. We’ll use the DisplayText action for this as well.
We’ll display “STAGE CLEAR” prominently in the center of the screen to make it feel like a proper clear.
The transition condition will be when the Remaining Enemies variable reaches 0.
Set Up the “Stage Clear” State
Switch to the RemainingEnemiesManager scene tab and change the editor view to Script.
What does “Use Scene as Base” mean?
Instead of using this object’s position, the display is anchored to the entire game scene—that is, the region shown by the camera. In this setup, the text box (1200×120) is centered on the scene, and STAGE CLEAR is centered within that box.
Right-click the Count state → Add Link → connect it to Stage Clear.
“The five enemies I placed aren’t there”:
They may have fallen offscreen. Make sure each enemy is placed on solid ground and that Don’t fall off ledges is enabled in Template Move.
“Nothing happens when the count reaches 0”:
Verify the Stage Clear state’s DisplayText settings, and confirm the link’s transition condition (Project Variable Remaining Enemies equals 0) is correct.
In this chapter, we learned about camera following mechanics, particles, UI, and variables, allowing the game to function as a proper game.
However, as it stands, the presentation is still rather plain, and there’s no sound.
In the next chapter, Chapter 5, we’ll enhance the game’s completeness by adding sound settings, background settings, and finally exporting the project so that anyone can play it.