Example #1
0
    private void Attack()
    {
        float eDistance = Vector3.Distance(target.transform.position, transform.position);

        Vector3 dir = (target.transform.position - transform.position).normalized;

        float direction = Vector3.Dot(dir, transform.forward);

        Debug.Log(direction);

        if (eDistance < 2.6f)
        {
            if (direction > 0)
            {
                PHealth eh = (PHealth)target.GetComponent("PHealth");
                eh.CurrentHealth(-10);
            }
        }
    }
Example #2
0
 void Awake()
 {
     player       = GameObject.FindGameObjectWithTag("Player");
     playerHealth = player.GetComponent <PHealth> ();
     anim         = GetComponent <Animator> ();
 }