Esempio n. 1
0
    protected virtual void OnTriggerStay(Collider other)
    {
        if (!isDependent)
        {
            if (enemyNav != null && enemyCanOpen && enemyObj == other.gameObject)
            {
                if (enemyNav.isOnOffMeshLink)
                {
                    if (!doorIsOpen && !doorChanging)
                    {
                        //speed *= 1.5f;
                        Debug.Log("Moving door to open because the enemy is accessing the offmeshlink");
                        moveDoor(true);
                    }

                    if (!doorChanging && !enemyIsWalkingThru && doorIsOpen)
                    {
                        //speed /= 1.5f;
                        enemyScript.enemyChasesPlayer = false;
                        StartCoroutine(agentLinkMover.MoveNavMesh());
                        enemyIsWalkingThru = true;
                        if (!enemyScript.playerTargeted)
                        {
                            StartCoroutine(closeDoorBehind());
                        }
                    }
                }
            }
        }
    }
    private void OnTriggerStay(Collider other)
    {
        NavMeshAgent   enemyNav = other.transform.root.GetComponent <NavMeshAgent>();
        AgentLinkMover mover    = other.transform.root.GetComponent <AgentLinkMover>();

        if (enemyNav != null && enemyNav.isOnOffMeshLink && !enemyIsWalkingThru)
        {
            if (mover != null)
            {
                enemyIsWalkingThru = true;
                StartCoroutine(mover.MoveNavMesh());
            }
            else
            {
                enemyNav.CompleteOffMeshLink();
            }
        }
    }