スピードを検出します.キャラクタコントローラがアサインされていることが必須です.
それと同じオブジェクトにアサインしてください.
#pragma strict
static var horizontalSpeed : float = 0.0;
function Start () {
}
function Update () {
var controller : CharacterController = GetComponent(CharacterController);
var horizontalVelocity : Vector3 = controller.velocity;
horizontalVelocity = Vector3(controller.velocity.x, 0, controller.velocity.z);
// The speed on the x-z plane ignoring any speed
horizontalSpeed = horizontalVelocity.magnitude;
//print(horizontalSpeed);
Debug.Log(horizontalSpeed);
}