using UnityEngine; using System.Collections; public class rigidbody_ : MonoBehaviour { private Rigidbody r; void Start () { //Rigidbody rb = GetComponent<Rigidbody>(); //float mass = rb.mass; //质量 //float drag = rb.drag;//空气阻力 //float angulaDrag = rb.angularDrag;//脚阻力 //rb.useGravity;//表示当前对象是否受到重量影响 //rb.isKinematic;//是否使用动力学 //rb.freezeRotation = false;//是否冻结游戏对象的旋转 r = GetComponent<Rigidbody>(); } void Update () { if (Input.GetKeyDown(KeyCode.UpArrow)) { print("up"); //给当前对象施加一个力 r.AddForce(new Vector3(0f, 1000f, 0f)); //给当前对象添加力矩/扭矩 //r.AddTorque(new Vector3(0, 10, 0)); //给对象添加一个指定在某个位置的力 //r.AddForceAtPosition(new Vector3(0, 10, 0), new Vector3(0.5f, 0.5f, 0.5f)); //在指定位置增加一个爆炸力;大小,位置,范围 //r.AddExplosionForce(1500f, Vector3.zero, 4f); } } }