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.

ControllerColliderHit.moveDirection

var moveDirection: Vector3;
Vector3 moveDirection;
moveDirection as Vector3

Description

Approximately the direction from the center of the capsule to the point we touch.

This can be used to find a reasonable direction to apply forces to touched rigidbodies.

	function OnControllerColliderHit(hit : ControllerColliderHit) {
		Debug.Log(hit.moveDirection);
	}
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    void OnControllerColliderHit(ControllerColliderHit hit) {
        Debug.Log(hit.moveDirection);
    }
}
import UnityEngine
import System.Collections

public class ExampleClass(MonoBehaviour):

	def OnControllerColliderHit(hit as ControllerColliderHit) as void:
		Debug.Log(hit.moveDirection)