Tutorial: Script Course #1 – Let's Create a Shooting Attack

In this course, you’ll learn the basics of scripting in ACTION GAME MAKER.
In Part 1, we’ll be creating a basic attack system.


:warning: Notes on Using Visual Scripts


:bookmark_tabs: Visual Scripts and Scene Tabs

Due to how Godot works, you can technically open any visual script tab regardless of which scene tab is currently active.
However, visual scripts in ACTION GAME MAKER depend on the nodes within the currently opened scene tab.

If you attempt to edit a visual script while a different scene is active, you won’t be able to access animation data, variables, or switches from the correct Game Object.

:small_blue_diamond: If this happens, don’t panic—just return to the correct scene tab without making changes to the script.


:file_folder: Visual Scripts and File References

Due to limitations in Godot, any references to other objects within an action—such as an object path—are stored as plain strings.

This means that if you move the referenced Game Object in the File System, the link will break and result in a missing reference.

While ACTION GAME MAKER provides a Missing Reference Check tool, fixing broken references across a large project is very time-consuming.

:white_check_mark: We strongly recommend organizing your folder structure properly before starting development.


:white_check_mark: Getting Started

Like the previous tutorials, this course uses the same tutorial project provided in the first course.
Please open the project now to get ready.

STEP 1: Create a Bullet Object – Bullet Setup


1. Let’s create a new Game Object scene.

In the center editor panel, click the + tab to open a new scene tab.
Then, in the Scene window, select Game Object.


2. In the object creation window, configure the following:

  • Object Name: Any name (we’ll use sample_bullet)
  • Template: bullets
  • Type: bullet_base
  • Group: Player

Then click the Create button.


3. A Game Object scene will be generated with the basic settings preconfigured.

Save the scene immediately by right-clicking the tab or pressing Ctrl + S, and save it wherever you like.


4. We need a visual for the bullet, but we don’t have an image file.

Instead, we’ll use a Godot node that draws a rectangle.
Click the + button in the top-left of the Scene window.


5. In the node selection dialog, go to:

Node > CanvasItem > Control > ColorRect and create it.
Use the search bar and type “Color” or “Rect” to find it easily.


6. A white rectangle appears.

It’s quite large by default, so let’s shrink it.
Select the ColorRect node in the Scene window.


7. In the Inspector, go to:

Layout > Transform and change the size from 40×40 to around 4×4.


8. The rectangle is drawn from the top-left corner, so let’s center it.

Set Position to:

  • x = -2
  • y = -2
    Now, the rectangle is centered on the scene origin.

image


9. The red semi-transparent rectangle represents the attack collision area, but it’s too large.

Let’s resize it.

  • Select AttackCollision in the Scene window.
  • Adjust the corners to make it slightly larger than the ColorRect.


10. The light blue translucent square (CollisionShape2D) is the wall collision area.

As it stands, the walls block the attack due to overlapping.
Let’s make the wall collider even smaller than the attack range.

Let’s resize it.

  • Select CollisionShape2D in the Scene window.
  • Adjust the corners to make it slightly smaller than the AttackCollision.


10. Now, select the MoveAndJumpSettings node.

By default, the horizontal and vertical movement speed is 100 px/sec, which is very slow.
Let’s increase it to around 300 px/sec.


11. Normally, you would also configure animations and other properties,

but for this simple bullet object, no additional setup is needed.

STEP 2: Create a Bullet Object – Bullet Script


1. Let’s create a new script.

Click the :scroll: (Scroll icon) at the top of the Scene window to create a new script.

image


2. Make sure the language is set to VisualScript, give it a name, and click Create.


3. Rename the first state node to Move, and enable the option to ignore gravity.


4. Go to Actions > + Add Executable Action and add an Attack Settings action.

Set the Hit Group to Enemy only, so the bullet won’t accidentally hit the player.


5. Add another state node and name it Remove.

Also enable the option to ignore gravity.


6. In the Remove state, add an Executable Action called RemoveSelf.

This removes the object from the game.
Always clean up bullets and enemies after use, or they’ll remain and consume system resources.


7. Right-click the Move state and create a link to the Remove state.


8. Set the first transition condition:

In the Inspector, go to Conditions > Add Condition, and choose Contact With Hit Area.
Set:

  • Direction: All
  • Target Group: Enemy

This means the bullet will be removed when it hits an enemy.


9. Add the second condition: Offscreen (when the bullet exits the camera view).

Set:

  • Target Type: This Node
  • Logical Condition with previous: OR

:warning: If you leave this as AND, both conditions must be true to trigger, which is not what we want.


10. Add the third condition: Contact With Tile.

Again, set direction to All, and combine it with OR.


:white_check_mark: Now, your bullet will be automatically removed if:

  • It hits an enemy
  • It goes offscreen
  • It collides with a tile

:light_bulb: TIPS

:firecracker: Remove vs. RestoreRemove, Disable vs. Enable

You may have noticed similar actions—here’s how they differ:

  • Remove: Completely deletes the object from the game. Best for items like bullets or enemies that don’t need to come back.
  • RestoreRemove: Revives a removed object but in a newly generated state. Original state is lost.
  • Disable: Temporarily disables the object without deleting it.
  • Enable: Reactivates a disabled object, restoring it exactly as it was.

:warning: Disabled objects still consume memory.
If you don’t plan to reuse them, use Remove instead.


:film_frames: If You Want to Add a Disappear Animation

In this example, we skipped animations for simplicity.
But if you want to show an animation before the bullet disappears, don’t call RemoveSelf directly after a hit.

Instead, add an intermediate “Hit” state between Move and Remove:

  1. Transition to Hit state on collision.
  2. Play an animation.
  3. Add a condition like “Animation Ended” or “Time Elapsed” to then transition to Remove.

STEP 3: Set the Bullet and Gun for the Player


1. Go back to the Object_Sampleplayer tab.

2. Click the Add Node button at the top-left of the Scene panel.


3. From Node > AGMaker, add a BulletSettings node.

This node manages the bullet to be fired.


4. Expand BulletDataList > + Add Bullet > <empty> > NewBulletData to create new bullet data.


5. Configure the basic bullet settings in Bullet Base Settings:

  • Name: Set any name (e.g., Sample_Bullet)
  • Object Path: Select the sample_bullet.tscn you created earlier.

:warning: If you move this file later, the reference will break.

  • Unlimited Bullets: Enable this option

(Details explained later.)


6. Set the Initial Behavior to FireObjectDirection, which fires the bullet in the direction the object is facing.


7. The bullet setup is now complete!

You can now fire sample_bullet in the direction the player is facing using the fire action.


8. Let’s attach a gun to the player.

Select AnimationPlayer, and try playing the animation 044_Gun_Aim.
The aiming animation plays, but the player still appears unarmed.


9. The gun image is included by default.

Navigate to templates > objects > weapons > P_other in the FileSystem.
Use W_005_gun.png. It fits well in the character’s left hand.


10. In the Scene panel, select:

BoneAnimationRoot2D > Skeleton > B_Chest > B_Joint_L > B_Arm_L > B_Hand_L > B_Weapon_L


11. With B_Weapon_L selected, drag and hold Shift while dropping W_005_gun.png near the hand.

This adds the image as a child node of B_Weapon_L.


12. If you did it correctly, W005Gun should be a child of B_Weapon_L.

If not, move it manually under the correct node.


13. Adjust the angle and position.

Select W005Gun and go to Node2D > Transform in the Inspector.
Set:

  • Position: x: 12, y: 21
  • Rotation: 156.4 degrees

:light_bulb: Even if the rotation is 0, the bone may already be rotated due to the animation, affecting the child.


14. Play the animation to make sure the gun looks correct while moving.

If everything looks good, let’s now adjust the gunfire origin.


15. Use a Connector node to specify the bullet firing point.

Although the character has a node called Connector - gun fire, it appears near the feet.
Move it to the muzzle of the gun.


:white_check_mark: Now your player has a bullet, a gun, and a correct firing point!


:hammer_and_wrench: Bullet Settings Explained

:small_blue_diamond: Basic Settings

  • Shot Count: Number of bullets fired per action.
    Can be used for burst fire or shotgun effects.

:warning: If the state changes mid-shot, firing stops.

  • Fire Interval: Interval between each bullet in multi-shot.
    • 0.3 sec = fire one bullet every 0.3 sec
    • 0 sec = fire all bullets simultaneously
  • Shot Limit: Maximum number of bullets on screen.
    • If 1, you must wait for the previous bullet to disappear.

:small_blue_diamond: Initial Behavior

  • Initial Behavior: How the bullet moves after being fired.

:warning: If the bullet’s script controls movement, that takes priority.

  • Spread Range: Degree of spread.
  • Spread Type:
    • Fixed: evenly spaced within spread angle
    • Wiper: swings back and forth while firing
    • Random: random angles within spread range

:small_blue_diamond: In-flight Behavior

Controls behavior after launch.
Examples:

  • Homing on locked targets
  • Boomerang-like arcs

:warning: Again, bullet’s own script has priority over these settings.

STEP 4: Fire the Bullet


1. Click the :scroll: icon next to Player to open the Visual Script.


2. Create a new Shoot state near Idle.

Set the animation to 044_Gun_Shoot.

:warning: If no animation appears, make sure the Object_SamplePlayer tab is open.


3. Add an executable action: Fire Bullet.

Set:

  • Bullet Data to Sample_Bullet
  • Connector to Connector - gun fire

This allows the player to fire Sample_Bullet from the muzzle.


4. Link Idle → Shoot.

Set the condition to: while the X button is pressed (C key on keyboard).


5. Link Shoot → Idle (shortcut).

Set the condition to: when the animation finishes.


6. If everything is set up correctly, the player should now be able to shoot.

Press :play_button: or hit F5 to test play.
If the bullet fires and disappears upon hitting a tile, success!


:hammer_and_wrench: Troubleshooting


:cross_mark: The firing animation doesn’t play

Check if the transition from Idle → Shoot is configured correctly and that the animation is properly set.


:cross_mark: The character stays in the shooting animation forever

The return transition from Shoot → Idle might not be set correctly.


:cross_mark: No bullets are fired

  • Make sure the Fire Bullet action is properly configured.
  • Confirm that:
    • The bullet data is assigned
    • The connector is set
    • The connector is placed correctly at the gun muzzle

:cross_mark: Only one bullet can be fired

Bullet limit may not be set to unlimited in the BulletSettings.


:cross_mark: Bullets never disappear

Check the Visual Script of sample_bullet.

  • Make sure:
    • Remove state has the correct RemoveSelf action
    • All 3 conditions are connected using OR, not AND

:right_arrow: Continue to Part 2

「いいね!」 1