About This Tutorial
In this tutorial we build a fire bullet that bounces as it flies, and along the way we explain
ACTION GAME MAKER’s “bullet” system
and how to make sprite animations.
We will use the project created in the “Jump Action Tutorial”.
ACTION GAME MAKER’s bullet system is set up in these steps:
- Create an object for the bullet
- Register it in the bullet settings of the object that fires it
- Fire it with the “Fire Bullet” action in the firing object’s visual script
Part 1: Let’s Make an Object for the Bullet!
First we will build the object for the bullet. This time we will explain how to make an animation from an image that is not in template format, and how to use the collision animation feature.
Part 1-1: How to Make a Sprite Animation Without a Template
A sprite animation is like a flip book: it animates by displaying images in order. Last time we loaded everything at once in template format; this time let’s learn how to build one by selecting each frame individually.
- Let’s prepare the image for the bullet. In the “Assets” view, click “Import official assets”.
- Select P_002_fire.png under “Weapon Images” and press “Import”.
- On the left side of the “Object” view, press “+ Create New” in the object list.
- Set
Object Name: Fire Bullet
Object Group: Player_Bullet
Collision role: Player bullet
then select “Bullet Base” in the lower pane and press “Create”.
- Switch to the Sprite Animation tab and press the “Use sprite animation” button.
- Press the “Add from sheet” button in the upper right.
- In the Add animation window, press “Add”.
- Name it “move” and press “OK”.
- The “Add frames from sheet” window opens, so press the “From Image List…” button.
- Choose the “P_002_fire.png” you just added and press “OK”.
- The image is added, but it is a little small, so let’s zoom in. Change the “Zoom” dropdown to 800%.
- Next, this image has 4 cells but is being treated as a single one, so let’s split it. Set Horizontal cells to “4”. Vertical lines appear on the image and it becomes 4 cells.
- Next, let’s match the collision size to the size of one cell. Press the “Adjust Initial Collisions” button.
- Both the wall collision and the attack collision look too big. Let’s adjust them.
- Move the wall collision handles to adjust it to roughly 8 wide and 12 high. (You can zoom the preview in and out with the mouse wheel.)
- Switch to the attack collision and adjust it. Make the attack collision slightly larger, about 12 wide and 16 high. When you are done, press “Confirm”.
- Finally, add the frames. They are loaded in the order you click them, so click 1, 2, 3, 4 in order starting from the leftmost cell, then press “Add”.
- The animation is now added. If the four images appear in the “Frame” field below, it worked.
- Try pressing the [
] button in the upper left of the window. You can preview the animation and see that the fire bullet now sparkles.
Part 1-2: Let’s Rotate the Image with Collision Animation!
- Change the tab to Collision Animation.
- Collision animation is a feature that lets you set the collisions and the image’s position, size, rotation and so on for each frame. Here we will set up the “Object image” to rotate.
First, select the object image in the “Element (some hidden)” field.
- From the 5 cells in the move (4 frames) field at the very bottom, select END.
Why is there an END at cell 5 when the animation only has 4 cells?
The simple animation feature sets a key (a state) at the moment each cell starts playing. With only 4 cells, you could not set the state at the end of the 4th cell — the state at the end of the loop — so an END cell is added automatically, for the collision animation only.
- In the Inspector on the right, under Node2D > Transform, set the “Rotation” value to 360. That sets the “Rotation” value at the end of the animation (this is called a key). The key for the first cell is automatically set to the state at creation time = 0 degrees, and the keys for the cells in between are interpolated automatically, so this is all you need to set.
- Try clicking the play button in the upper left of the window — the image should spin around. If it does not work, check that you really set the END cell to 360 degrees; you may have forgotten to switch and set the first cell to 360 instead.
Why does the END cell's rotation read 359.9 after playback finishes?
It is a display-only issue. When loop playback is enabled, playing back returns automatically to the 0-second point at the 360-degree state — the true END state — so what you see is the state just before it wraps around. END does have the correct value of 360, so there is no problem.
Part 1-3: Let’s Change the Movement Speed and Gravity Settings!
Next, let’s give it movement befitting a bullet. It needs to be faster than the player, and since it bounces, it needs to be affected by gravity. (Ordinary bullets are not affected by gravity, so the template disables gravity.)
-
Switch to the Preview tab and select “Move and jump” in the element list.
-
In the Inspector on the right, under Movement Speed Settings, set
Horizontal Speed: 500
Vertical Speed: 500
-
A little below that, the Gravity Rate value under Jump Settings is 0, so set
Gravity Rate: 5.0
The default gravity rate is 1.0, so this applies 5 times the normal gravity to this bullet. Normal gravity makes the movement feel floaty, so deliberately applying strong gravity gives it a snappier motion.
-
The object setup is now complete. Let’s “Save” it just to be safe.
Part 2: Let’s Set Up the Bullet’s Visual Script!
Next, let’s set up a visual script for the bullet.
- Press Edit Visual Script.
- Press the button to create a visual script.
- Change State001 as follows:
Animation to assign > Animation Category: move
Title: Move
- Press “+ Add Executable Action” on the “Move” state.
In the left pane, choose Move > TemplateMoveAction (template move settings).
In the right pane, set the Move Template Type to Bound and turn on “Bound Bounce Gravity”.
Bound is movement that bounces when the object hits something collidable, which makes it bounce when it hits the ground.
About the template move action
Once executed, “TemplateMoveAction” keeps performing the specified movement until another template move tells it to “stop”. In other words, it keeps the same motion even across multiple states, which makes it handy for objects that only move in simple ways. The “Enemy” left-right movement is built with it too.
- Next, let’s set up disappearing when it hits an enemy. Create a new state nearby, rename it to Remove, and press “+ Add Executable Action”.
- Add “RemoveSelf” from Disappear/Revive.
- Finally, set up the link. Connect a link from the “Move” state to the “Remove” state and press “+ Add Condition”.
- In the left pane, choose Object Control > ContactWithHitArea (contact with an object’s hit collision).
In the right pane, enable all directions for the contact direction as seen from the object, set the target object type to Group and the target object group to “Enemy”, then add it.
- It now disappears when it hits an enemy, but as things stand the bullet never disappears unless it hits one. Let’s make it disappear when its wall collision hits something from the side. Press “+ Add Condition” once more.
- In the left pane choose “ContactWithBody”. In the right pane set
Incoming contact direction as seen from this object: Left, Up, Right (!!not Down — if you include Down, the bullet disappears on the ground instead of bouncing!!)
Connection With Previous Condition: “OR”
This part is easy to get wrong, so check it carefully before adding.
- Look at ContactWithBody: if the icon correctly says “OR”, you are good. The bullet side is now fully set up.




























































