Intro to 2D Character Movement - Godot Beginner Tutorial by Code With Ro (Patreon)
This tutorial video is designed as a beginner-friendly follow-along project that guides viewers through building a 2D player controller, showing how project organization, sprite setup, movement logic, physics, input handling, camera behavior, and animation states are structured and implemented in the Godot Engine to create a functional 2D moving character. It also served as the foundation for completing a structured implementation task on Feather, with the project integrated into the wider development workflow supporting the Handshake AI Project Moonstone initiative.
Halloween Graphics by Jason Perry (Pateron)
Step 1: Context setting
Please include the following context-setting data about the tutorial and segment you selected.
OS version: Windows 11 Pro
Application version: Godot Engine v4.5.1.stable.official [f62fdbde1]
Description of the task/project you selected
The selected task will implement basic 2D player movement in the Godot Engine using an animated character PNG sprite, including keyboard input handling and movement logic. This task will follow a YouTube video tutorial titled "Intro to 2D Character Movement - Godot Beginner Tutorial" created by Code With Ro, using the time segment from approximately 00:16 to 28:40.
- Start Point: https://youtu.be/kw1iI69kW6o?si=H5SCbQFy0Fhqdm27&t=16
- End Point: https://youtu.be/kw1iI69kW6o?si=ZpcuOGbL_V12ZPaD&t=1720
In this segment, the tutorial demonstrates how to use an animated character sprite from a PNG image, configuring the required nodes, setting the collision and physics for the sprite asset, defining input actions, writing GDScript for frame-independent movement, and modifying the 2D environment. The starting state is a new Godot project with a basic empty scene, and the ending state is a playable scene where the player character sprite can move in four directions within a grey 2D game environment.
Briefly describe the inputs to / input state of this project.
The input state consists of a newly created Godot project in which a simple 2D environment gets set up to move an animated Grim Reaper sprite asset from the Halloween Graphics pack created by finalbossblues on itch.io. I will use the "reaper_blade_1.png" image file in the "reaper" folder from the graphics pack as the only sprite asset for the 2D character movement and animation frames in this task. https://finalbossblues.itch.io/halloween-graphics
Step 2: Task completion
Screen recordings and intermediate artifacts.
Brief description of the breakpoint-1
Following a YouTube video tutorial, I created a new Godot project named "Tutorial," organized it with assets, scenes, and scripts folders, and imported the "reaper_blade_1.png" image from the Halloween Graphics pack as the first animated asset. I then created a 2D game scene and a separate player scene, added a "CharacterBody2D" node with an "AnimatedSprite2D" child node, and configured the sprite sheet as a 3×4 grid to define the initial "idle_down" animation frame. To improve visual clarity, I changed the project's default texture filter to "Nearest," centered the sprite in the 2D environment, and positioned it above the y-axis to establish the character sprite's starting point.
Brief description of the breakpoint-2
Continuing the YouTube video tutorial, I added three directional idle animation frames to the sprite asset, named them "idle_left," "idle_right," and "idle_up," and selected the appropriate idle sprites from the sprite sheet grid. I then created walking animations by adding four frames named "walk_down," "walk_left," "walk_right," and "walk_up," each using three sprites from the sheet grid to animate directional movement. Finally, I added a "CollisionShape2D" child node to the "Player" node and selected a "CircleShape2D" collision area for the sprite's body, and then dragged the "player.tscn" scene into the center of the 2D game scene.
Brief description of the breakpoint-3
Working with the video tutorial, I added a camera to the game scene by configuring a "Camera2D" child node and adjusting its zoom for better visibility of the sprite asset within the 2D environment. I then defined keyboard input actions for directional movement by navigating to Input Map within Project Settings, and added new actions named "move_down," "move_up," "move_left," and "move_right" and assigned them to keybinds using "S," "W," "A," and "D." Finally, I programmed a GDScript to the "Player" node and implemented the core movement logic, utilizing variables for speed and direction, and using a "_physics_process(delta)" function for smooth movement and collision handling.
Brief description of the breakpoint-4
Concluding the video tutorial, I debugged an issue where the sprite asset continued moving after releasing the input key by using print statements to track direction variables and adding a new "play_idle_animation" function to handle the sprite's idle state when it's not moving. I also discovered that the idle animation was incorrectly using the current direction instead of the "last_direction," and I fixed that issue by adding an else statement in the "_physics_process(delta)" function that calls the "play_idle_animation" function. After resolving the bugs, I unparented the "Camera2D" node to observe the sprite's movement and adjusted the "max_speed" variable to show its effect on the sprite's movement speed.
Step 3: Task specification
Prompt reference file(s).
Reference link/description
Intro to 2D Character Movement - Godot Beginner Tutorial by Code With Ro: https://www.youtube.com/watch?v=kw1iI69kW6o
Reference link/description
Grim Reaper Sprite Asset from the Halloween Graphics Pack by finalbossblues: https://finalbossblues.itch.io/halloween-graphics
Final Prompt
Create a playable 2D scene environment with a resolution of 1152 x 648 in the Godot Engine, featuring a controllable player character using an animated sprite. The project should depict a small pixelated sprite of a grim reaper carrying a scythe as the sole character asset, displayed clearly without texture blurring in a 2D scene with an entire background color of #4d4d4d. The player character must move smoothly in four directions using the W, A, S, and D keys, play the correct walking animation while moving in each direction, and switch to a direction-specific idle animation when movement stops. Each movement direction must use its own distinct walking animation, and each idle state must use its own distinct idle animation for up, left, right, and down. When the input key is released, the player character must immediately stop and face the last direction moved, with distinct idle animations for up, left, right, and down. In the Input Map settings, there must be input actions with keybindings named "move_up" mapped to W, "move_left" mapped to A, "move_right" mapped to D, and "move_down" mapped to S. The player character should move to the left when pressing the A key, the player character should move to the right when pressing the D key, the player character should move up when pressing the W key, and the player character should move down when pressing the S key. The player character must use a 2D circle collision shape area to provide physics-based collision handling that supports smooth, controlled 2D movement, along with programmed animation logic that clearly distinguishes between idle and walking states for each movement direction. Use a camera node to display the character player in the center of the scene, and ensure the movement speed is adjustable through a configurable variable named "max_speed" in the GDScript code. The final result should be a functional and responsive 2D player movement system that demonstrates animation structure, input handling, collision setup, and real-time movement behavior within Godot.
Rubric Items
- The playable game is a 2D scene environment.
- Open the game scene and confirm that it uses a type "Node2D" node to view the scene in the 2D editor.
- The prompt requires that the project have a playable 2D game scene environment.
- The project's viewport width is 1152.
- Verify that the Viewport Width value is equal to 1152 by navigating to "Project Settings," then "Display," and then "Window."
- The prompt requires that the project's resolution be 1152 x 648. Because these values are adjustable individually, they should each receive partial credit.
- The project's viewpoint height is 648.
- Verify that the Viewport Height value is equal to 648 by navigating to "Project Settings," then "Display," and then "Window."
- The prompt requires that the project's resolution be 1152 x 648. Because these values are modifiable individually, they should each receive partial credit.
- The scene's background color is colored to #4d4d4d.
- Confirm that the Default Clear Color hex value is equal to #4d4d4d by clicking on "Project Settings," then "Rendering," and then "Environment."
- The prompt requires that the entire scene background have a color of #4d4d4d.
- The sprite asset uses a small pixelated Grim Reaper carrying a scythe.
- Run the game scene and visually confirm that only the pixelated Grim Reaper sprite is visible as the player character.
- The prompt requires that the correct sprite asset of a grim reaper carrying a scythe must be the only player character for the project.
- The sprite asset renders without any blurry texture.
- Confirm that the Default Texture Filter is assigned to "Nearest" by clicking on "Project Settings," then "Rendering," and then "Textures."
- The prompt requires that the sprite asset have a clearly visible pixel-art texture.
- Pressing W on the keyboard moves the character sprite upward.
- Run the game scene and press the W key to observe the upward movement direction.
- Pressing the W key should cause the sprite asset to move up, as required by the prompt.
- Pressing A on the keyboard moves the character sprite to the left.
- Run the game scene and press the A key to observe the left movement direction.
- Pressing the A key should cause the sprite asset to move left, as required by the prompt.
- Pressing D on the keyboard moves the character sprite to the right.
- Run the game scene and press the D key to observe the right movement direction.
- Pressing the D key should cause the sprite asset to move right, as required by the prompt.
- Pressing S on the keyboard moves the character sprite downward.
- Run the game scene and press the S key to observe the downward movement direction.
- Pressing the S key should cause the sprite asset to move down, as required by the prompt.
- The character sprite stops moving immediately when input is released.
- Run the game scene, press any movement key, then release the movement key, and observe whether movement ceases instantly.
- The prompt requires that the character sprite stop moving immediately when any pressed input key is released.
- The idle animation faces up after the upward movement stops.
- Run the game scene, move the player character upward, release the W input key, and inspect the idle animation facing direction.
- The prompt requires the character sprite to face up as the last movement direction when the upward input is released.
- The idle animation faces left after the leftward movement stops.
- Run the game scene, move the player character left, release the A input key, and inspect the idle animation facing direction.
- The prompt requires the character sprite to face left as the last movement direction when the leftward input is released.
- The idle animation faces right after the rightward movement stops.
- Run the game scene, move the player character right, release the D input key, and inspect the idle animation facing direction.
- The prompt requires the character sprite to face right as the last movement direction when the rightward input is released.
- The idle animation faces down after the downward movement stops.
- Run the game scene, move the player character downward, release the S input key, and inspect the idle animation facing direction.
- The prompt requires the character sprite to face down as the last movement direction when the downward input is released.
- The sprite triggers upward-walking animations while moving up.
- Run the game scene, press and hold the W key, and inspect that the player character's walking animation moves upward.
- The prompt requires that the upward walking animations transition appropriately when the player character moves up.
- The sprite triggers leftward-walking animations while moving left.
- Run the game scene, press and hold the A key, and inspect that the player character's walking animation moves leftward.
- The prompt requires that the leftward walking animations transition smoothly when the player character moves left.
- The sprite triggers rightward-walking animations while moving right.
- Run the game scene, press and hold the D key, and inspect that the player character's walking animation moves rightward.
- The prompt requires that the rightward walking animations transition smoothly when the player character moves right.
- The sprite triggers downward-walking animations while moving down.
- Run the game scene, press and hold the S key, and inspect that the player character's walking animation moves downward.
- The prompt requires that the downward walking animations transition smoothly when the player character moves down.
- The player character has a 2D collision circle area enabled.
- Open the player scene and inspect that it uses a "CollisionShape2D" node with a 2D circle shape for physics collision.
- The prompt requires that the player character include appropriate physics and collision handling to support controlled movement.
- A camera node is present that displays the sprite in the scene's center.
- Open the game scene and confirm that it uses a type "Camera2D" node to display the character sprite in the center of the 2D scene.
- The prompt requires that the game scene have a camera node to display the player character at the center of the scene environment.
- The sprite's movement speed is adjustable by a configurable variable.
- Inspect the GDScript code for a modifiable "max_speed" variable affecting the movement speed of the sprite.
- The prompt requires that the GDScript code have an adjustable movement speed through a modifiable variable.
- The Input Map includes a "move_up" action bound to the W key.
- Verify an action exists with the W key assigned by navigating to "Project Settings" and then to "Input Map" to see the "Action" list. The prompt requires that the W key be assigned as a keyboard input action to control the player character.
- The Input Map includes a "move_left" action bound to the A key.
- Verify an action exists with the A key assigned by navigating to "Project Settings" and then to "Input Map" to see the "Action" list.
- The prompt requires that the A key be assigned as a keyboard input action to control the player character.
- The Input Map includes a "move_right" action bound to the D key.
- Verify an action exists with the D key assigned by navigating to "Project Settings" and then to "Input Map" to see the "Action" list.
- The prompt requires that the D key be assigned as a keyboard input action to control the player character.
- The Input Map includes a "move_down" action bound to the S key.
- Verify an action exists with the S key assigned by navigating to "Project Settings" and then to "Input Map" to see the "Action" list.
- The prompt requires that the S key be assigned as a keyboard input action to control the player character.
Godot - https://feather.openai.com/tasks/22a9f089-26f7-44e6-9a0c-f7c5cb95f95b - Signed off.
