CharacterController.detectCollisions 检测碰撞

var detectCollisions : bool


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.


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;
Page last updated: 2010-12-14