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 gameObject: GameObject;
GameObject gameObject;
gameObject as GameObject

Description

The game object that was hit by the controller.

	// Objects we touch, move them to position (0, 0, 0)
	function OnControllerColliderHit(hit : ControllerColliderHit) {
		hit.gameObject.transform.position = Vector3.zero;
	}
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    void OnControllerColliderHit(ControllerColliderHit hit) {
        hit.gameObject.transform.position = Vector3.zero;
    }
}
import UnityEngine
import System.Collections

public class ExampleClass(MonoBehaviour):

	def OnControllerColliderHit(hit as ControllerColliderHit) as void:
		hit.gameObject.transform.position = Vector3.zero