Animation like in "Scratch" coding language

Godot Version

<4.2.1 →



when it comes to animating a player movement in Godot I know two methods.

  1. With the Animation Player Node which can be controlled with the keyboard

  2. Or letting the animation run down a “Path node”.

What I´m interested in is an animation with “Tween”, because it seams to come the closest to my experience with “Scratch”.

I don´t want to controll the player with the keyboard or use the “Path Node”. I want to let him go down a path on his own while he is running his walking animation.

I understand how to let a player change his position with a tween command, but I don´t know how he goes through his walking animation while moving.

So the script will look similar to:
go to x,y
change to frame 1
go to x,y
change to frame 2

I hope I made my intention clear.
Thank you for your help.

The AnimationPlayer node is not controlled by the keyboard.
It is a timeline based control.
The animation happens as the AnimationPlayer moves from one point in time to another.
Those points in time are called ‘key frames’ and often shortened to just ‘keys’.
The sprite image (or other node) is adjusted according to the property changes imposed by the next key.
For example if the keys are animating the position property, the position of the sprite changes between keys (it interpolates the change so that the sprite ‘moves’ from the position in one key to the position described by the next key).
The keys exist along a ‘track’ and there may be multiple tracks in a single animation with each track handling a specific property of the node.
Additionally, the AnimationPlayer keys don’t have to be the properties of a node, but they can call script functions and a few other actions (track types).
What you are describing is perfectly suited to the AnimationPlayer
I recommend searching out some tutorials on its use.

1 Like

thank you! I will look it up!

I can use the Animated Player now but I am not realy convinced yet.
I think the goal I´m following is different. I´m not going to script a typical game as the engine intends.

I may have to declare my selfe a bit more.
I am teaching kids how to play guitar and want to script a learning software.

I want to create a story, in which the game character is following a scriptet story, like an endless cut scene. No outside movement controll by the user.

On his way he solves tasks and explaines guitar playing in short animated lessons which I already made in “Scratch” with greate succes to my surprise.

The tasks could be: “click on the right note”, “multiple choice questions” , “play these note sheet” and some related mini games intendet for touch screens. Unfortunately Scratch doesn´t have a folder system which prevents bigger projects and also the possibility to export to an exe or apk file.

I´m still thinking like a “Scratch developer” and have a hard time to actualy understand how to work with Godot after 2 intense weeks of trying. Maybe I need more time.

Most tutorials are going straight forward into a pretty narrow path of developing the same game over and over again and are lacking giving tools to play around with. Often times these tools are poorly described.

In the screenshot you can see what I´m comfortable working with. Might be pretty harsh for guys with experienced.

Is there a possibility to shorten this script with a “for loop”?
With something like “self.position.x +=10” and “$Sprite2D.frame +=1”
I wasn´t succsesfull solving this yet.

I’m not sure if understand correct what you are aiming for. But as I see, it will be a 2d side scrolling character, but it will move scripted right? If so, you should use path2d node to control the movement path of the character. Look for path tutorials on godot and you will find. Then you could react based on the position of the path.

1 Like

thank you for your answer.
Yes I think I can set this up but I get stuck with putting several actions together like:

-walking a scripted path

  • stoping
  • walking again
  • playing a sound
  • let another character move
  • a flashing light fills the screen
  • then another object apears

There are tutorials for all of these subjects which I might be able to copy without actually understanding what I´m doing and hoping that the script is still working in my version of Godot(!). Then to put all these parts together I feel overwhelmed when trying.

I might have to keep learning and go up the hill. The thing is with Scratch I was able to understand and put things together by suspicion. With Godot it is a completly different thing but I might have to accept it.

Most walking tutorials focus on keyboard commands. This little peace of starting a movement with a button or other signal for example is missing for me.

Got it. Maybe is just the way of thinking that is different. But we are getting there!
You can use the Path2d, the add a pathfollow2d node as a child. There are two properties in pathfollow2d node you can use to track the progress:

• progress
• progress_ratio

You can attach a script that will increase the progress over time. Then you can check where in progress you are and add actions like you said.

PathFollow2D Documentation

1 Like

thnank you, I will try it. :pray:

Can you share an animation that you made in Scratch that shows what you are attempting?

Thank you! I hope this link works:

There is still sound missing and some polishing but I guess you get the idea.

Also here is another projekt I made in 16:9 format on a mod of scratch which unfortunately doesn´t allow big uploads, thats why it´s in 4:3 ratio.

It is clear to me that a real programming language like GDscript cant be compared to scratch. So I will work my way through to learn it. The YouTube Chanel GDQuest offers a free app to learn GDscript and I like it very much so far. I will keep on learning.

Thank you very much for all of your fast and helping answers.
I guess with the on going digitalization of society programming will develope to become more easy over time.