[Solved] Diagonal movement is faster on player

How do I…

Make diagonal movements be the same speed as the straights?

What is the expected result

If you didn’t knew, it’s really common for a top-down movement to be faster while in moving in diagonals. This is because when you move diagonally, you move 1 pixel vertically and 1 pixel horizontally. That means, you move faster in the diagonal.
So, to fix this, I tried doing this, using a mathematical equation to calculate the hypotenuse of this movement:


This is, basically, a² + b² = c²
I don’t know exactly how to explain it, but here’s the video I used as reference: How to fix your diagonal movement! - YouTube

What is the actual result

Nothing happens, basically. The player, as it seems, continues to move faster diagonally.

Related screenshots


  • Just to clarify, I am applying these movements on a custom behavior
  • The max speed is the same on vertical and horizontal movement
  • The default max speed is 2.5
  • The acceleration and decceleration are both 0,125
1 Like

Why not use the top-down movement behavior?
https://wiki.gdevelop.io/gdevelop5/behaviors/topdown/

Because in this case, I don’t feel like its way of movement is what I want
I tried it, but it has some weird direction changing and I just prefer doing it manually

Here’s 2 gifs showing a comparison:

  • Using the default top down behavior:
    ezgif.com-crop
    (Seems much smoother than it actually is)

  • Using my version:
    ezgif.com-crop (1)

Is it the sharp turns that you want to avoid?

1 Like

Yes, it is the sharp turns that I want to avoid

Just solved it out:

1 Like