Unity 刚体常用方法

刚体:Rigidbody;
void Start () {

GetComponent().AddForce(Vector3.up*3);//给刚 体施加力
GetComponent().AddExplosionForce(19.0f,transform.positi
on,10,1.5f,ForceMode.Force);//施加爆炸力
 
GetComponent().AddRelativeForce(Vector3.up*10,ForceM ode.Force);//施加相对力

GetComponent().AddTorque(- Vector3.right*70,ForceMode.Force); //施加力矩

GetComponent().AddRelativeTorque(- Vector3.right*70,ForceMode.Force); //施加相对力矩

}
void FixedUpdate () {
GetComponent().MovePosition(transform.position + Vector3.right*Time.deltaTime);//移动刚体
,参数为移动目的地址
GetComponent().MoveRotation(transform.rotation*Quaterni on.Euler(new Vector3(0,100,0)*Time.deltaTime));//旋转物体

GetComponent().AddForceAtPosition(Vector3.up,transform. position,ForceMode.Force);//在指定点施加力
}


你可能感兴趣的:(unity)