var speed : float;
var deviation : float;
private var animator : Animator;
function Start () {
rigidbody2D.velocity.x = speed;
}
function OnCollisionEnter2D (other : Collision2D) {
if(other.gameObject.tag == "Player"){
rigidbody2D.velocity.x = -speed;
rigidbody2D.velocity.y = Random.Range(-deviation, deviation);
StartCoroutine("Hit", 0);
}
if(other.gameObject.tag == "AI"){
rigidbody2D.velocity.x = speed;
rigidbody2D.velocity.y = Random.Range(-deviation, deviation);
StartCoroutine("Hit", 0);
}
if(other.gameObject.tag == "Top Wall"){
rigidbody2D.velocity.y = Random.Range(0, -deviation);
}
if(other.gameObject.tag == "Bottom Wall"){
rigidbody2D.velocity.y = Random.Range(0, deviation);
}
if(other.gameObject.tag == "Restart"){
Application.LoadLevel(0);
}
}
function Hit () {
animator.SetBool("Hit", true);
yield WaitForSeconds(.25);
animator.SetBool("Hit", false);
}
Returns NullReferenceException due to this function.
function Hit () {
animator.SetBool("Hit", true);
yield WaitForSeconds(.25);
animator.SetBool("Hit", false);
}
Though, I do not know why. Help?