Rigidbodyを使用した以下の4つの基本的な移動方法を試しました。

【次の瞬間の移動先を指定する】
  • position: 完全な瞬間移動
  • MovePosition: ほぼ瞬間移動(中間位置を補間できる)
【最初に速度や力を与える】
  • velocity: その瞬間の速度を直接変更
  • AddForce: その瞬間に力を加える
(参考元はUnityマニュアル。

以下のようにY軸方向に一定速度で移動していきます。
青:position緑:MovePosition赤:velocity黄:AddForce


Rigidbody Componentの設定と、このC#ソースは以下です。
Unity_Rigidbody_Test_01
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MoveTest : MonoBehaviour {
    Rigidbody RB;
    Vector3 moveDirection;
    void Start () {
        moveDirection = new Vector3 (0, 1, 0);
        RB = this.GetComponent <Rigidbody> ();
        if (this.name == "Velocity")
            // velocityの設定
            RB.velocity = moveDirection * 1.0f;
        else if (this.name == "AddForce")
            // AddForceの設定
            RB.AddForce(moveDirection * 50.0f);
    }
    void FixedUpdate() {
        if (this.name == "Position")
            // positionの設定
            RB.position = RB.position + moveDirection * 0.02f;
                 else if (this.name == "MovePosition")
            // MovePositionの設定
            RB.MovePosition (RB.position + moveDirection * 0.02f);
    } }



Sponsored Link