// Update is called once per frame void Update() { BasicEnemyController enemyController = this.gameObject.GetComponent <BasicEnemyController>(); if (enemyController.canGoToPrimaryTarget) { InputHandler.HandleMovementInputTargeted(this.gameObject, this.axisVVal, this.isRunning, enemyController.PrimaryTarget); this.angleInDegreesToTarget = InputHandler.HandleRotationInputTargeted(this.gameObject, enemyController.PrimaryTarget); } else { ScriptedGoalHandler goalHandler = this.gameObject.GetComponent <ScriptedGoalHandler>(); InputHandler.HandleMovementInputTargeted(this.gameObject, this.axisVVal, this.isRunning, goalHandler.Goals[goalHandler.currentGoalIndex]); this.angleInDegreesToTarget = InputHandler.HandleRotationInputTargeted(this.gameObject, goalHandler.Goals[goalHandler.currentGoalIndex]); } }
// Update is called once per frame void Update() { this.randPrimaryMovementPercentVal = Random.Range(primaryMinMovementPercent, primaryMaxMovementPercent); this.timeLimitForPrimaryMovementState = Random.Range(primaryMinTimeLimitMovementState, primaryMaxTimeLimitMovementState); this.timeInPrimaryMovementState += Time.deltaTime; this.randSecondaryMovementPercentVal = Random.Range(secondaryMinMovementPercent, secondaryMaxMovementPercent); this.timeLimitForSecondaryMovementState = Random.Range(secondaryMinTimeLimitMovementState, secondaryMaxTimeLimitMovementState); this.timeInSecondaryMovementState += Time.deltaTime; if (this.PrimaryTarget != null) { Vector3 distanceBwPlayer = this.transform.position - this.PrimaryTarget.transform.position; ScriptedGoalHandler goalHandler = this.gameObject.GetComponent <ScriptedGoalHandler>(); if ((Mathf.Abs(distanceBwPlayer.magnitude) < this.maxMagnitudeToPlayer) && (Mathf.Abs((goalHandler.Goals[goalHandler.currentGoalIndex] - this.transform.position).magnitude) < this.maxMagnitudeToGoal)) { this.canGoToPrimaryTarget = true; } else { this.canGoToPrimaryTarget = false; } } else { this.canGoToPrimaryTarget = false; } this.PrimaryMovementState(); this.SecondaryMovementState(); if (this.canGoToPrimaryTarget) { Debug.DrawRay(this.transform.position, (this.transform.position - this.PrimaryTarget.transform.position).normalized * this.forwardMagnitude); } }
// Update is called once per frame void Update() { ScriptedGoalHandler goalHandler = this.gameObject.GetComponent <ScriptedGoalHandler>(); if (goalHandler == null) { return; } BasicEnemyController enemyController = this.gameObject.GetComponent <BasicEnemyController>(); if (enemyController.canGoToPrimaryTarget) { currGoal = enemyController.PrimaryTarget.transform.position; } else { currGoal = goalHandler.Goals[goalHandler.currentGoalIndex]; } navAgent.destination = currGoal; //Debug.DrawRay(this.transform.position, this.transform.forward * this.forwardMagnitude); }