回答編集履歴
3
詳細の追加とコードの修正
    
        answer	
    CHANGED
    
    | @@ -1,1 +1,38 @@ | |
| 1 | 
            -
            完成を止めたい瞬間に[`Rigidbody.velocity = Vector3.zero`](https://mogi0506.com/unity-rigidbody-stop/)を実行。
         | 
| 1 | 
            +
            完成を止めたい瞬間に[`Rigidbody.velocity = Vector3.zero`](https://mogi0506.com/unity-rigidbody-stop/)を実行。
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            質問者様の場合、
         | 
| 4 | 
            +
            ```C#
         | 
| 5 | 
            +
            using System.Collections;
         | 
| 6 | 
            +
            using System.Collections.Generic;
         | 
| 7 | 
            +
            using UnityEngine;
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            public class PlayerController : MonoBehaviour
         | 
| 10 | 
            +
            {
         | 
| 11 | 
            +
                Rigidbody2D rigid;
         | 
| 12 | 
            +
                public float walkForce = 15.0f;
         | 
| 13 | 
            +
                private Vector2 inputAxis;
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                private void Start()
         | 
| 16 | 
            +
                {
         | 
| 17 | 
            +
                    this.rigid = GetComponent<Rigidbody2D>();
         | 
| 18 | 
            +
                }
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                private void Update()
         | 
| 21 | 
            +
                {
         | 
| 22 | 
            +
                    inputAxis.x = Input.GetAxis("Horizontal");
         | 
| 23 | 
            +
                    inputAxis.y = Input.GetAxis("Vertical");
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                    if(Input.GetKeyUp(KeyCode.W) || Input.GetKeyUp(KeyCode.S) || Input.GetKeyUp(KeyCode.A) || Input.GetKeyUp(KeyCode.D))
         | 
| 26 | 
            +
                    {
         | 
| 27 | 
            +
                        rigid.velocity = Vector2.zero;
         | 
| 28 | 
            +
                    }
         | 
| 29 | 
            +
                }
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                private void FixedUpdate()
         | 
| 32 | 
            +
                {
         | 
| 33 | 
            +
                    rigid.velocity = inputAxis.normalized * walkForce;
         | 
| 34 | 
            +
                }
         | 
| 35 | 
            +
             | 
| 36 | 
            +
             | 
| 37 | 
            +
            }    
         | 
| 38 | 
            +
            ```
         | 
2
詳細の追加とコードの修正
    
        answer	
    CHANGED
    
    | @@ -1,1 +1,1 @@ | |
| 1 | 
            -
            [Rigidbody.velocity = Vector3.zero](https://mogi0506.com/unity-rigidbody-stop/)
         | 
| 1 | 
            +
            完成を止めたい瞬間に[`Rigidbody.velocity = Vector3.zero`](https://mogi0506.com/unity-rigidbody-stop/)を実行。
         | 
1
コードの修正
    
        answer	
    CHANGED
    
    | @@ -1,2 +1,1 @@ | |
| 1 | 
            -
            [Rigidbody.velocity = Vector3.zero;
         | 
| 2 | 
            -
            ](https://mogi0506.com/unity-rigidbody-stop/)
         | 
| 1 | 
            +
            [Rigidbody.velocity = Vector3.zero](https://mogi0506.com/unity-rigidbody-stop/)
         | 
