[SOLVED] Object keeps sliding?

My object keeps sliding after transforming it but only on one axis, can someone help me find out why?

moving left and right makes it slide continious in the direction it was going
and going up and down does not…

public class Player : MonoBehaviour
    private float turnSpeed = 15f;

    private float moveSpeed = 1f;

    private Rigidbody rigidbody;

    private Collider collider;

    public void Awake()
        rigidbody = GetComponent<Rigidbody>();
        collider = GetComponentInChildren<Collider>();

    private void FixedUpdate()
        float v = Input.GetAxisRaw("Vertical");
        float h = Input.GetAxisRaw("Horizontal");

        if (
            Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.W) ||
            Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.DownArrow) || Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.RightArrow))
            Move(h, v);

    private void Move(float horizontal, float vertical)
        //Rotating(horizontal, vertical);
        MovePlayer(horizontal, vertical);

    void MovePlayer(float horizontal, float vertical)
        Vector3 targetDirection = new Vector3(horizontal, 0f, vertical);

        transform.position += targetDirection * moveSpeed * Time.deltaTime;

    void Rotating(float horizontal, float vertical)
        Vector3 targetDirection = new Vector3(horizontal, 0f, vertical);

        Quaternion targetRotation = Quaternion.LookRotation(targetDirection, Vector3.up);

        Quaternion newRotation = Quaternion.Lerp(rigidbody.rotation, targetRotation, turnSpeed * Time.deltaTime);



As toromano said, in your comment,
Making your rigidbody kinetic should solve the problem,
If you dont know where to find the option it on the inspector when you select your player,
and look towards the rigidbody part there should be a bool saying is kinetic,
or you could enable kinetic rigid body by code using:

public class ExampleClass : MonoBehaviour {
    public Rigidbody rb;
    void Start() {
        rb = GetComponent<Rigidbody>();
    void EnableRagdoll() {
        rb.isKinematic = false;
        rb.detectCollisions = true;
    void DisableRagdoll() {
        rb.isKinematic = true;
        rb.detectCollisions = false;

I took the code from the unity scripting API, wasn’t too hard to find,
Good luck with your game,

add physics material to ground and object .sets its friction value to something like 0.6 and set the property rigidbody > interpolate to none