// Update is called once per frame void Update() { if (player_within_pursue_range.Execute(agent) == AIBehaviour.BehaviourResult.Success) { aibehaviour2.Execute(agent); melee_animator.SetInteger("Speed", 1); } else { aibehaviour.Execute(agent); melee_animator.SetInteger("Speed", -1); } if (player_within_attack_range.Execute(agent) == AIBehaviour.BehaviourResult.Success) { aibehaviour3.Execute(agent); melee_animator.SetBool("isAttacking", true); // if the player is within attack range, sets the attack animation to play } else { melee_animator.SetBool("isAttacking", false); // otherwise, sets it not to } if (health <= 0) { Destroy(agent.gameObject); } }
// Update is called once per frame void Update() { if (attackRange.Execute(agent) == AIBehaviour.BehaviourResult.Failure) { aibehaviour.Execute(agent); rangeEnemyAnimator.SetBool("isWalking", true); rangeEnemyAnimator.SetBool("isShooting", false); } if (attackRange.Execute(agent) == AIBehaviour.BehaviourResult.Success) { aibehaviour2.Execute(agent); rangeEnemyAnimator.SetBool("isWalking", false); } if (attackRange2.Execute(agent) == AIBehaviour.BehaviourResult.Success) { aibehaviour3.Execute(agent); rangeEnemyAnimator.SetBool("isShooting", true); } if (health <= 0) { Destroy(agent.gameObject); } }
// Update is called once per frame void Update() { waited += Time.deltaTime; if (waited < Frequency) { return; } string ailog = ""; float BestAIValue = float.MinValue; AIBehaviour bestAI = null; aiSupport.GetSupport(gameObject).refresh(); foreach (var ai in aiBehaviours) { ai.TimePassed += waited; var aiValue = (ai.GetWeight() * ai.WeightMultiplier) + Random.Range(0, Confusion); ailog += ai.GetType().Name + ":" + aiValue + "\n"; if (aiValue > BestAIValue) { BestAIValue = aiValue; bestAI = ai; } } //Debug.Log(ailog); bestAI.Execute(); waited = 0; }
void FixedUpdate() { behave.Execute(); if (selected) { CameraFollow(); } }
// Update is called once per frame void Update() { waited += Time.deltaTime; //checks if enough time has been spent to perform another action if (waited < Frequency) { return; } if (CurrentAction != null) { //checks if an action is already active if (CurrentAction.CurrentlyAttacking == true) { return; } } string AIDebug = ""; //sets variables for choosing the best AI option float BestAIValue = float.MinValue; AIBehaviour bestAI = null; //runs through each AI option in the list, gets the weight of each one and multiplies it by a randomness factor foreach (var ai in Ais) { ai.TimePassed += waited; var AIValue = ai.GetWeight() * ai.WeightMultipler + Random.Range(0, AIRandomness); AIDebug += ai.GetType().Name + ": " + AIValue + "\n"; //if the current AI option has a higher weight than the last, it replaces the current as the best option if (AIValue > BestAIValue) { BestAIValue = AIValue; bestAI = ai; } } //Debug.Log(AIDebug); //executes the best AI option bestAI.Execute(); CurrentAction = bestAI; waited = 0; }
public void OnUpdate() { EvaluateBehaviours(); currentBehaviour?.Execute(); }
public void OnUpdate() { currentBehaviour?.Execute(); }