Rigidbody.detectCollisions 碰撞检测

var detectCollisions : bool

Description描述

Should collision detection be enabled? (By default always enabled)

碰撞检测应否启用?(默认总是启用的)

Disabling collision detections is useful when you have a ragdoll which is setup to be kinematic and you want to avoid heavy collision detection calculations on that rigidbody. detectCollisions is not serialized. This means it doesn't show up in the Inspector and when Instantiating the rigidbody or saving it in a scene, it will not be saved.

当你有一个布娃娃,它被设置为运动学并且你想避免刚体上大量的碰撞检测计算时,禁用碰撞检测是很有用的。detectCollisions是非序列化的,也就是说,它不会显示在检视面板中并且当在场景中实例化或保存它时,它将不被保存。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public void Awake() {
		rigidbody.isKinematic = true;
		rigidbody.detectCollisions = false;
		rigidbody.isKinematic = false;
		rigidbody.detectCollisions = true;
	}
}
// Let animation control the rigidbody and ignore collisions
//让动画控制这个刚体并忽略碰撞

rigidbody.isKinematic = true;
rigidbody.detectCollisions = false;
// Let the rigidbody take over control, detect collisions
//让刚体接管控制,检测碰撞

rigidbody.isKinematic = false;
rigidbody.detectCollisions = true;
Page last updated: 2011-2-9