//Checks to see if the axe has been picked up public override bool checkComplete(GOAPAgent agent) { var anim = agent.GetComponentInChildren <Animator>(); if (agent.Target != null) { if (anim.GetBool("hasPickedUp")) { var controller = agent.GetComponentInParent <PlayerController>(); if (controller != null) { controller.SetHandObject(agent.Target); } anim.SetBool("hasPickedUp", false); return(true); } else { return(false); } } else { return(false); } }
public override void onActivation(GOAPAgent agent) { //Get NavMesh Agent NavMeshAgent navAgent = agent.GetComponentInParent <NavMeshAgent>(); //Set a random destination in the radius Vector3 randomDirection = Random.insideUnitSphere * 18; randomDirection += transform.position; NavMeshHit hit; NavMesh.SamplePosition(randomDirection, out hit, 18, 1); Vector3 finalPosition = hit.position; navAgent.SetDestination(finalPosition); //Set the animation Animator agentAnimator = agent.GetComponentInParent <Animator>(); agentAnimator.SetBool("walking", true); }
public override bool checkComplete(GOAPAgent agent) { //Get NavMesh Agent NavMeshAgent navAgent = agent.GetComponentInParent <NavMeshAgent>(); if (!navAgent.pathPending) { if (navAgent.remainingDistance <= navAgent.stoppingDistance) { if (!navAgent.hasPath || navAgent.velocity.sqrMagnitude == 0f) { //Set the animation Animator agentAnimator = agent.GetComponentInParent <Animator>(); agentAnimator.SetBool("walking", false); return(true); } } } return(false); }
//A simple way to set goals. Shoul be replaced with an actual method of getting the highest priority goalSet and setting it's goals public override List <GOAPState> getWorldState(GOAPAgent agent) { List <GOAPState> worldData = new List <GOAPState>(); var controller = agent.GetComponentInParent <PlayerController>(); bool hasAxe = false; if ((controller != null) && (controller.hand.GetComponentInChildren <InteractableItemBase>() != null)) { hasAxe = (controller.hand.GetComponentInChildren <InteractableItemBase>().tag != null); } worldData.Add(new GOAPState("FirewoodCollected", false)); worldData.Add(new GOAPState("HasAxe", hasAxe)); worldData.Add(new GOAPState("FirewoodAvailable", GameObject.FindGameObjectsWithTag("Firewood").Length > 0)); return(worldData); }