Example #1
0
    private void OnCollisionStay(Collision collision)
    {
        if (collision.rigidbody && collision.gameObject.tag == "Player")         //if the target of the collision has a rigidbody, try to do damage to it
        {
            attackFrequency -= Time.deltaTime;
            Debug.Log("Colliding with rigidbody");
            if (attackFrequency <= 0.0f)
            {
                if (!anim.GetBool("Attack"))
                {
                    anim.SetBool("Attack", true);
                }

                Hero_Health heroHealth = collision.collider.GetComponent <Hero_Health>();   // checks to see if the object attacked has a EnemyHealth script
                heroHealth.TakeDamage(m_damagePerHit);
                attackFrequency = startingFreq;
            }
        }
    }
Example #2
0
 // Use this for initialization
 void Start()
 {
     player     = GameObject.FindGameObjectWithTag("Player");
     healthInfo = player.GetComponent <Hero_Health>();
 }