# Trying to recreate 2d sonic running animation

i’m fairly new to gdevelop, and i’m trying to make my own 2d Sonic game. But i’m facing a problem with his running animation.

His running animation (12 sprites) starts with Sprite 1, where he starts moving slowly, but to Sprite 10 to 12, it’s his max speed running.

But if i just make make the animation with Sprite 1 to 12, it will repeat everything, while i just want 10 to 12 to repeat once Sprites 1 to 9 appeared on screen.

Any ideas how can i do that?

1 Like

You need two animations, while accelerating set the jogging(?) animation (the non full speed one), you can even increase the animation speed in function of the player speed to accelerate the animation along the player.
When the player reaches a high speed, set the running animation (the full speed one), and switch to the lower speed animation again if the player speed is reduced.

PS: If you want to make a full Sonic game you’ll face problems with the loops

Interesting. How can i adapt it to the character speed then? I found nothing in the animation window for that.

Concerning the loops, well, i’m not there yet, i will think about that after, the character works properly.

There is an action for sprites to set the animation speed scale, a scale = 1 means common speed, a scale = 2 means the animation will be played twice as fast, you can do something like this:

``Do = (PlayerCurrentSpeed * 2) / PlayerMaxSpeed to the animation speed scale of Player``

This way if the current speed is the half of the max speed the animation speed scale will be 1, and if the current speed reaches the max speed the scale will be 2. But getting the current speed and max speed depends on the behavior or system used, check the animation speed scale example

I’m trying to recreate it perfectly, based on the original physics, like that.

imgur.com/a/Mz3Jm

For now here’s what i did:

Animation of Jogging :

imgur.com/a/bcvWx

Animation that i want when he reach Max Speed :

imgur.com/a/YfxA0

My Events so far :

imgur.com/a/0R0E1

Based on the events you posted, the next step is to create two sub-events of the “Joueur is moving” sub-event which check the speed and change the animation when maximum speed is reached.

```1 overall speed of Joueur is < Joueur.PlatformerObject::MaxSpeed() | Do =1 to the number of current animation of Joueur 2 overall speed of Joueur is = Joueur.PlatformerObject::MaxSpeed() | Do =2 to the number of current animation of Joueur```

Hi, i added the two sub events you’re talking, but my character is still doing Animation 1…

imgur.com/a/LUP09

For information, the Max Speed of the character is 250.

As I said:

The problem is that the condition “Overall speed of Object” doesn’t work for the Platformer behavior because it doesn’t use built-in forces, to get the current speed check this:
[url][GD5] Displaying Player's Speed on the Example Platformer]
The example uses two methods, an approximation through expressions and an exact solution through JavaScript (web only), I recommend the approximation

So… I can’t switch between my two animations when my character runs, just by using events?

Yes you can , check the example, when I say “through expressions” I mean through events, using the expressions to get the player position (Player.X(), Player.Y()) you can get the player delta position, the expression TimeDelta() gives the delta time, finally speed = delta position / delta time

I read your events in the zip file. And i really don’t understand. I thought that GDevelop was as easy to use that of Project Spark…

As I said before, you just have to get the delta position (player.x - previous player.x) and the delta time, easy as:

I did as you said, now my events look like that :

imgur.com/a/KD0tH

But that didn’t change anything. My Sonic dont change his animation.

Ok, what my events do is get the player speed and save it in a variable “speed”, now you have to change the conditions:

``Overall speed of Player < (or =) Player.PlatformerObject::MaxSpeed()``

to

``Variable(speed) is < (or =) Player.PlatformerObject::MaxSpeed()``

Done.

imgur.com/a/BiRK1

Doesn’t change…

Sorry, it’s “Variable speed is < …” without parentheses, also “speed” is a scene variable, not an object variable of Jouer (there are other conditions for scene and global variables)

Like that?

imgur.com/a/TDt2o

Yes, but use the scene variable condition:

EDIT: Wait!, in the last image you’ve set “speed” as a global variable, now you need to use the global variable condition when checking the max speed.

You have to choose one: object, scene or global:

Now it looks like that:

imgur.com/a/oe3ZQ

Still doesn’t allow the character to do what i want.