Example #1
0
 void OnTriggerStay2D(Collider2D other)
 {
     if (isChargingRight == false && isChargingLeft == false && isOnCooldown == false)
     {
         if (other.gameObject.GetComponent <PlayerConroller> () == player)
         {
             if (player.GetComponent <Rigidbody2D> ().position.x < rBody.position.x && Mathf.Abs(player.GetComponent <Rigidbody2D> ().position.y - rBody.position.y) < 3)
             {
                 isChargingLeft  = true;
                 chargeStartTime = Time.time;
             }
             else if (player.GetComponent <Rigidbody2D> ().position.x > rBody.position.x && Mathf.Abs(player.GetComponent <Rigidbody2D> ().position.y - rBody.position.y) < 3)
             {
                 isChargingRight = true;
                 chargeStartTime = Time.time;
             }
         }
     }
 }