CharacterController.detectCollisions 检测碰撞

var detectCollisions : bool

Description描述

Should other rigidbodies or character controllers collide with this character controller (By default always enabled)

其他的刚体和角色控制器是否能够与本角色控制器相碰撞(默认值始终启用)

This method does not affect collisions detected as part of the character movement. Instead it controls collisions between the controller and other objects. For example a box will block the movement of the controller, but the box can fall through the controller as part of the simulation. This is useful to temporarily disable the character controller. Eg. you might want to mount a character into a car and disable collision detection until you exit the car again. Note that this only affects other bodies to not collide with r detectCollisions is not serialized. This means, it doesn't show up in the inspector and when Instantiate'ing the controller or saving it in a scene it will not be saved.

这个方法不影响被检测为角色运动部分的碰撞。相反,它控制控制器与其他物体之间的碰撞。例如,一个盒子将阻碍控制器的运动,但是盒子作为部分模拟能够穿过控制器。这对于暂时禁用角色控制器来说是非常有用的。例如,你可能想把一个人物放进一个汽车里并且禁用碰撞检测,直到你又走出汽车。注意,这只影响其他的物体,使它不与没有序列化的r检测碰撞相碰撞。它的意思是,它并不在检视面板中显示,而且当在场景中实例化或者保存控制器时,它将不被保存。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public CharacterController c;
	public void Awake() {
		c = GetComponent<CharacterController>();
		c.detectCollisions = false;
	}
}
var c : CharacterController;
c = GetComponent(CharacterController);
c.detectCollisions = false;
最后修改:2010年12月14日 Tuesday 14:56

本脚本参考基于Unity 3.4.1f5

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