Exemple #1
0
    // Update is called once per frame
    // LateUpdate is the same, but its called after the normal Update()-s, which means it will be after the EnemyScripts's Update, and that all the variables will be up-to-date
    void LateUpdate()
    {
        //get the vector data from the enemy handler
        dirToTarget  = myHandler.GetDirToPlayer();
        distToTarget = myHandler.GetDistToTarget();

        //myHandler.GetTargetVectorData(ref dirToTarget, ref distToTarget);

        //if (distToTarget > distToStop && distToStart > distToTarget)
        {
            MoveInDir(dirToTarget);
        }
    }
Exemple #2
0
    // Update is called once per frame
    // LateUpdate is the same, but its called after the normal Update()-s, which means it will be after the EnemyScripts's Update, and that all the variables will be up-to-date
    void LateUpdate()
    {
        //get the vector data from the enemy handler
        dirToTarget  = myHandler.GetDirToPlayer();
        distToTarget = myHandler.GetDistToTarget();

        //myHandler.GetTargetVectorData(ref dirToTarget, ref distToTarget);

        //if (distToTarget > distToStop && distToStart > distToTarget)
        {
            Vector3 oppositeDir = new Vector3(-1 * dirToTarget.x, -1 * dirToTarget.y, 0);
            MoveInDir(oppositeDir);
        }
    }
Exemple #3
0
    // Update is called once per frame
    void Update()
    {
        //get the vector data from the enemy handler
        dirToTarget  = myHandler.GetDirToPlayer();
        distToTarget = myHandler.GetDistToTarget();

        //myHandler.GetTargetVectorData(ref dirToTarget, ref distToTarget);

        if (curCooldown > 0)
        {
            curCooldown -= Time.deltaTime;
        }
        else// if (distToTarget < distToAttack)
        {
            Attack();
            curCooldown = cooldown;
        }
    }
    // Update is called once per frame
    void Update()
    {
        //this is so when we get activated, theres a bit of time before the enemies start attacking
        if (!isAwake)
        {
            timePassed += Time.deltaTime;

            if (timePassed >= timeToWakeUp)
            {
                WakeUp();
            }

            if (!isAwake)
            {
                return; //if we still arent awake, do nothing
            }
        }

        distToPlayer = myHandler.GetDistToTarget();

        DecideState();
    }