How to stop a sphere from moving by itself after restarting its position?
<p>I am on my third day of learning Unity and are currently doing the <a href="https://unity3d.com/learn/tutorials/projects/roll-ball-tutorial" rel="nofollow noreferrer" title="roll-a-ball tutorial">roll-a-ball tutorial</a>. I am trying to add a restart button, that teleports the ball back to the start-position/origin. It all works good, but the ball will keep moving after I restart, but I want it to stay in a spot and not move by itself.</p>

<p>What I mean is that if I'm moving left at max speed and press 'R' to restart, then it will keep moving left fast for some time, but what I want to achieve is that the ball would not keep moving by itself after I restart it's position (perhaps it's speed is just decreasing so slow that it's unnoticeable, in which case I'd want it to slow down faster).</p>

<p>Here's my code that I just tried out and "hoped" would work, but doesn't. I think that the problem I have here is that a new axisHorizontal/axisVertical variable value is assigned again the next frame, the value being taken from <em>Input.GetAxis</em>, which from what I have heard is not possible to change.</p>

<p>That means that a movementForce bigger than 0/0/0 and AddForce will be activated again the next frame.</p>

<pre><code>using UnityEngine;
using System.Collections;

public class PlayerScript : MonoBehaviour {

    public float movementSpeed = 7f;
    private Rigidbody rigidSphere;

    void Start() {
        rigidSphere = GetComponent&lt;Rigidbody&gt;();
    }

    void FixedUpdate() {
        float axisHorizontal = Input.GetAxis("Horizontal");
        float axisVertical = Input.GetAxis("Vertical");

        Vector3 movementForce = new Vector3(axisHorizontal, 0.0f, axisVertical);
        rigidSphere.AddForce(movementForce * movementSpeed);

        if (Input.GetKeyDown(KeyCode.R)) {
            transform.position = new Vector3(0, 0, 0);
            rigidSphere.AddForce(0, 0, 0);
            axisHorizontal = 0;
            axisVertical = 0;
        }
    }
}
</code></pre>

<p>I tried googling on how to change the value that is taken from GetAxis, but others claim it's impossible to do so. So I have really no idea how to make it not keep moving forever...</p>

<p>And I also got a 'bonus' question that has arised during those two days that I have been learning Unity, but they are not worth a seperate question, perhaps if they have been already answered before (I've been unable to find any documentation that'd help me on it), then just give me a link on where I could find the answer to my problem.</p>

<p>The question is that how do I make the ball stop moving after some time after I press a button (W/A/S/D, the default values for positive/negative buttons in Input Manager)? For example, I press 'W' just for a second, but the ball will keep moving forward forever and will never stop.</p>

<p>What I want to achieve is after I for example press 'W' for a second, after a few seconds the ball will completely stop, it just seems that the value from GetAxis never goes back to 0. I tried to google about it, and I think it's something to do with Gravity in the Input Manager - I tried changing it, but the ball will still keep moving forever, the only thing I noticed did change was the speed of the ball.</p>

<p>I'd be really grateful if someone could help me with these problems.</p>