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.
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
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
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
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
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
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)