Rigidbody.collisionDetectionMode 碰撞检测模式

var collisionDetectionMode : CollisionDetectionMode

Description描述

The Rigidbody's collision detection mode.

刚体的碰撞检测模式。

Use this to set up a Rigidbody's for continuous collision detection, which is used to prevent fast moving objects from passing through other objects without detecting collisions. For best results, set this value to CollisionDetectionMode.ContinuousDynamic for fast moving objects, and for other objects which these need to collide with, set it to CollisionDetectionMode.Continuous. This has a big impact on physics performance, so just leave it set to the default value of CollisionDetectionMode.Discrete, if you don't have any issues with collisions of fast objects. Continuous Collision Detection is only supported for Rigidbodies with Sphere-, Capusle- or BoxColliders.

使用这个创建一个刚体的连续碰撞检测,从没有碰撞检测的其他物体传递,用来防止快速移动的物体,为了获得最佳效果,为快速移动的物体设置这个值为CollisionDetectionMode.ContinuousDynamic,以及为其他与之需要碰撞的物体设置这个值,为CollisionDetectionMode.Continuous。这个对物理性能有很大影响,所以只要给它设置为默认值 CollisionDetectionMode.Discrete,假如快速物体的碰撞没有任何问题。连续碰撞检测只支持刚体的球体、胶囊或盒子碰撞器。

参考:[CollisionDetectionMode]

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public void Awake() {
		rigidbody.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
	}
}
// Turns the attached to collider into a trigger.
//转换附加碰撞器为触发器

rigidbody.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
Page last updated: 2011-2-9