How to move player at a constant speed along its X axis

I am making a 2D runner game and I wanted to make the player move at a constant speed of 5 units per second along the x-axis regardless of its movement on the y-axis.

Similar to Geometry Dash’s player movement if you know about it.

    public float speed = 5f;
    void FixedUpdate() 
    {
    transform.Translate(Vector2.right * Time.deltaTime * speed);
    }

This is the script I am using right now however its x-axis movement gets slowed down when it’s moving on a slope to compromise with the y-axis movement, which is something I don’t want.

A video that might make what I said more clear

I have also tried addforce and changing player velocity but they don’t work the way I want either.

Can anyone give me a solution? Any help will be appreciated!

Try to add a physic Material with very low friction to your player.
Also, if you move in FixedUpdate you dont have to multiply with DeltaTime, because the time between FixedUpdates is allways the same.
Time.deltaTime is the time between Updates and not FixedUpdates