🎮 Tutorial Godot do Zero 2025 #4 – Animações via Código com AnimatedSprite2D
Implementing Player Animations in Game Development
Introduction to Player Animation
- The video begins with a recap of the previous session, where the player animation for the idle state was created and adjustments were made to the screen layout.
- The current focus is on enabling the player character to turn left while walking, as it currently only faces right.
Modifying Player Orientation
- The presenter navigates back to the player scene, emphasizing that all modifications will occur within this dedicated area.
- To flip the player's orientation, they explore properties in the Animated Sprite 2D settings, specifically looking at horizontal flipping (Flip H).
Coding Adjustments for Animation
- Instead of using inspector settings directly, changes will be implemented through code by accessing specific node references.
- A method for obtaining a reference to the Animated Sprite 2D node is demonstrated by dragging and dropping while holding control.
Understanding Variable Declaration
- Explanation of variable declaration in GDScript includes defining a new variable type (AnimatedSprite2D), which allows manipulation of sprite properties via code.
- The presenter clarifies how referencing nodes works within the game’s structure and emphasizes updating references if node names change.
Physics Processing Logic
- An overview of physics processing reveals checks for whether the player is on solid ground or falling due to gravity.
- Input handling is discussed; pressing left or right adjusts direction values (-1 for left, +1 for right), allowing movement control.
Direction-Based Animation Logic
- The logic for determining player direction based on input values is outlined; zero indicates no movement.
- A temporary coding solution is proposed to test functionality before refining it into a more robust version later.
Conditional Statements in Code
- An
ifstatement checks if direction values indicate movement; actions are taken based on whether it's positive or negative.
- If moving right (positive value), Flip H remains false; if moving left (negative value), Flip H becomes true.
Testing Movement Functionality
- After implementing directional checks, testing confirms that animations correctly reflect movement directions when pressing keys.
Adding New Animations: Walking and Jumping
- With basic movement functioning correctly, attention shifts towards creating additional animations such as walking and jumping.
- A new animation named "walk" is added by importing images from an existing asset package.
Configuring Animation Properties
- Each frame's configuration involves setting up six frames horizontally with one vertical line for smooth walking animation playback.
Adjusting Frame Rate
- Frame rates are adjusted to enhance animation speed; both walk and idle animations are set to 10 FPS for better visual fluidity.
Looping Animations
- Infinite looping options are enabled for continuous animations like walking and idling but disabled for single-frame actions like jumping.
Integrating Animation Changes into Code
- Code integration ensures that when moving right or left, corresponding animations play appropriately based on direction inputs.
Finalizing Jump Animation Setup
- A jump animation setup follows similar steps as previous ones but focuses on a single image since it's not looped.
Implementing Ground Check Logic
- Before executing jump-related actions in code, a check confirms whether the player character is grounded using
is_on_floor.
Testing All Animations Together
- Comprehensive testing shows successful transitions between idle, walking, and jumping states during gameplay interactions.
Conclusion & Next Steps
- Viewers are encouraged to subscribe and stay tuned for future videos focusing on camera mechanics following player movements.
Turn any video into a summary like this
YouTube links, meetings, lectures. With transcripts, search, and chat.


