人为移动rigidbody的位置

using UnityEngine;
using System.Collections;


public class RgbodyTest : MonoBehaviour {


    //public GameObject body;
    private Rigidbody2D rgbody;
    private float i = 0.0f;
// Use this for initialization
void Start () {
        rgbody = gameObject.GetComponent();
}

// Update is called once per frame
void Update () {
        Vector2 vec2 = new Vector2(i, -2.26f);
        rgbody.MovePosition(vec2);
        i = i + 0.05f;
        //body.MovePosition(vec2);
}
}

你可能感兴趣的:(unity3d)