EnemyScript.Update C# (CSharp) Method

Update() public method

public Update ( ) : void
return void
    void Update()
    {
        /** MOVEMENT VALUES **/
        if (targetLocation != null)
        {
            dir = destinationCache - this.transform.position;                // The vector to move along to reach target location
        }

        distThisFrame = movespeed * Time.deltaTime;                                 // How far the unit moves in a frame

        /** STATE SWITCHING LOGIC **/
        if (targetPathNode != null && targetPathNode.barricade != null && !attacking)
        {
            attacking = true;
            beginAttacking = true;
            beginPathing = false;
            targetBarricadeCache = targetPathNode.barricade;                        // Cache the Barricade the unit is
            StartCoroutine("Combat");
        }

        else if (beginPathing)
        {
            if (!moving)
                StartCoroutine("MoveToTarget");

            Pathfinding();
        }
    }