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;
最后修改:2011年2月9日 Wednesday 15:06

本脚本参考基于Unity 3.4.1f5

英文部分版权属©Unity公司所有,中文部分© Unity圣典 版权所有,未经许可,严禁转载 。