Example #1
0
    //checks if the next Lerp in a movement has a wall or an enemy
    //@pre canPhase
    //@param checkLocation position to be lerped to
    //might change targetLocation to current transform.
    bool CheckLerpPoint(Vector3 checkLocation)
    {
        float checkRadius = GetComponent <CapsuleCollider>().radius;

        Collider[] hitColliders = Physics.OverlapSphere(checkLocation, checkRadius);
        foreach (Collider hit in hitColliders)
        {
            if (hit.tag == "Enemy" || hit.tag == "Barrier")
            {
                Debug.Log("Stop");
                //check if going to spawn in a legal location
                if (InLegalLocation(transform.position) && hit.tag == "Enemy")
                {
                    attackScript.CallAttack();
                }
                return(false);
            }
        }
        if (!canPhase)
        {
            foreach (Collider hit in hitColliders)
            {
                if (hit.tag == "OutOfBounds")
                {
                    Debug.Log("Hit a wall...");
                    return(false);
                }
            }
        }
        return(true);
    }