I have this written up in FixedUpdate:
function FixedUpdate(){
var velController : CharacterController = GetComponent(CharacterController);
var horizontalVelocity : Vector3 = controller.velocity;
horizontalVelocity = Vector3(controller.velocity.x, 0, controller.velocity.z);
//The speed on the x-z plane
var horizontalSpeed : float = horizontalVelocity.magnitude;
I want to be able to call the horizontalSpeed variable from within a OnTriggerEnter like this:
function OnTriggerEnter (col : Collider){
if(horizontalSpeed <= 1 && col.gameObject.tag == "Turret" )
{
Debug.Log("KABOOM");
}
}
I can’t put the OnTriggerEnter inside the FixedUpdate, and I get an UnknownIdentifier error leaving it as is. I know this is probably more stackexchange worthy because is a generic programming thing more than a Unity specific thing, but I tried looking around there and googling “javascript + how to call a variable inside another function” and got nothing I could use. If you could help me despite that fact I would really appreciate it.