Rigidbody player keeps moving after AddForce has stopped?

So, i have my player setup, there’s just one problem now.
When i press my vertical/horizontal inputs, and then release them the rigibody doesn’t stop moving.
It keeps moving for an unlimited amount of time.
Any fixes for this? Code :

    using UnityEngine;
    using System.Collections;

    public class CharacterMovement : MonoBehaviour {

    Rigidbody rigidbody3D;
    public float speed = 4;

    void Start () 

        rigidbody3D = GetComponent<Rigidbody>();

	void FixedUpdate () 

        // Checks for user inputs.
        float horizontal = Input.GetAxis("Horizontal");
        float vertical = Input.GetAxis("Vertical");

        Vector3 movement = new Vector3(horizontal, 0, vertical);

        // Makes the player move.
        rigidbody3D.AddForce(movement * speed / Time.deltaTime);

        // Limits the speed of the rigidbody.
        if (rigidbody3D.velocity.magnitude > speed)
            rigidbody3D.velocity = rigidbody3D.velocity.normalized * speed;



Fixed it by adding a drag value to my rigidbody!

The main problem is that Rigidbody.AddForce adds a force to a rigidbody that will make it keep going. You can think of it like throwing a ball. When you throw the ball, your hand adds force to the ball. Even after the ball leaves your hand, it will keep going even though no more force is being added.

You can instead use Rigidbody.MovePosition or simply set the position of the rigidbody if you don’t want your rigidbody to keep going even after the movement keys are released. Another option is to set the velocity property of the rigidbody. However, this can sometimes lead to unrealistic physics behavior if you set it every frame.

Another minor thing is that you should multiply by Time.deltaTime, not divide by it on line 26. That way there will be more force for a larger delta time and less force for a smaller delta time.

To control the movement and the force of the game object better use the “Rigidbody.Addforce.”

This way you can control your player’s movement and your player won’t just go through other objects with the Rigidbody component.
Using “Rigidbody.MovePosition”, the game object just passes through other objects irrespective of the components attached to it.

    void Update()


    private void MovePlayer()
        float horizontalMovement =  Input.GetAxis("Horizontal") * speed;
        float verticalMovement = Input.GetAxis("Vertical") * speed;
        playerRb.AddForce(Vector3.forward * verticalMovement);
        playerRb.AddForce(Vector3.right * horizontalMovement);