Is it possible to use block coding for implementing the animations of a 2d characterbody? #399
-
Hi - just tried out block coding for a project and I saw that it was fairly intuitive. Just wanted to ask if there exists a way to implement sprite animations depending on the actions of the player? Also, what would happen if there was a block code and a script attached to the same node? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I've tested and found 1 method that works that requires a keyboard (to hold ctrl while dragging). I used a simple scene tree with the Block Code node attached to the Sprite2D. Then I dragged a 2-by-2 sprite sheet that I drew into the texture property under the inspector. I also set the appropriate horizontal and vertical frames. I also made a Block Code script using the Sprite2D's frame property by both dragging it and dragging it while holding the ctrl key from the inspector. This method animated the sprite in my case, although it wasn't my first thought process. When I tried to use an animated texture and from it drag its frames property, the block wouldn't appear, probably because of some incomplete reference. I think that it would be possible to include an option to drag in blocks without holding ctrl for touch input devices. Also, it appears that Block Code overrides/replaces other scripts initially attached to the node. |
Beta Was this translation helpful? Give feedback.
-
Hello @RealGabrielDelRosario, is good to know that you find block coding intuitive! This is how I would do it:
Keep in mind that the CharacterBody2D node in Godot is only for physics, has nothing to do with the visual aspect of your character. In this case I did frame by frame animations with an AnimatedSprite2D node, but you can do any sort of animation. Grabacion.de.pantalla.desde.2025-08-12.10-15-47.webmSorry for the issues in the video, my recording is not working well today. But hopefully these screenshots are better: ![]() ![]() ![]() |
Beta Was this translation helpful? Give feedback.
Hello @RealGabrielDelRosario, is good to know that you find block coding intuitive! This is how I would do it:
Keep in mind that the CharacterBody2D node in Godot is only for physics, has nothing to do with the visual aspect of your character. In this case I did frame by frame animations with an Anim…