'How can I program my movement to be more "linear"

I'm having a bit of an issue with movement. The game is a 3D FPS and the current code I have has a few issues and I was wondering how I would go about making "Minecraft Like" movement.

public Rigidbody PlayerRb;

public Transform PlayerTran;

public float speed = 2500f;
void Update()
{

    if (Input.GetKeyDown("w"))
    {
        PlayerRb.AddForce(PlayerTran.forward * speed);
    }

    if (Input.GetKeyDown("a"))
    {
        PlayerRb.AddForce(PlayerTran.right * -speed);
    }

    if (Input.GetKeyDown("s"))
    {
        PlayerRb.AddForce(PlayerTran.forward * -speed);
    }

    if (Input.GetKeyDown("d"))
    {
        PlayerRb.AddForce(PlayerTran.right * speed);
    }

}

If anyone could help me make better movement that would be greatly appreciated. I am pretty new so sorry if I don't get it the first time.



Solution 1:[1]

Fixed all issues with this code https://github.com/Saharsh1223/Minecraft-player-movement-in-unity-free-download/blob/main/Assets/Scripts/PlayerMovement.cs

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 MIthrilDragon