Legacy Documentation: Version 4.5.0

Script language:

  • JS
  • C#
  • Boo
Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

var collider: Collider;
Collider collider;
collider as Collider

Description

The collider that was hit by the controller.

	// Paint red the collider we hit.
	function OnControllerColliderHit(hit : ControllerColliderHit) {
		hit.collider.renderer.material.color = Color.red;
	}
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    void OnControllerColliderHit(ControllerColliderHit hit) {
        hit.collider.renderer.material.color = Color.red;
    }
}
import UnityEngine
import System.Collections

public class ExampleClass(MonoBehaviour):

	def OnControllerColliderHit(hit as ControllerColliderHit) as void:
		hit.collider.renderer.material.color = Color.red