private void Update() { //if we are idle, we do behaviour for moving if (Controller.Move_State == AgentControl.Agent_State.Idle) { Controller.AgentWander(); } }
private void OnTriggerEnter(Collider other) { //if the other object is a navagent. if (other.gameObject.GetComponent <AgentControl>()) { AgentControl other_agent = other.gameObject.GetComponent <AgentControl>(); //compare clearance of agent against the access level of this space. if (other_agent.clearance_level >= access_required) { //has clearance, we do nothing. } else { //doest have clearance. We tell the agent to go away. Debug.Log(other_agent.name + " is not authorised to access : " + Area_Name); //spawns an object to show visual feedback that an agent has been denied access. Instantiate(AccessDeniedPrefab, new Vector3(other.gameObject.transform.position.x, other.gameObject.transform.position.y + 2.0f, other.gameObject.transform.position.z), Quaternion.identity, other.gameObject.transform); other_agent.AgentWander(); } } //we want an event for the player as well to display whether or not they are allowed into a specific area. Works into the keycards/disguises to add later. //Display on player UI that they are tresspassing if they are by checking the players current credentials if (other.gameObject.tag == "Player") { if (other.gameObject.GetComponent <PlayerManager>().Current_Clearance >= access_required) { //player has clearance at this moment in time. other.gameObject.GetComponent <PlayerManager>().isTrespassing = false; } else { //Player is currently trespassing. other.gameObject.GetComponent <PlayerManager>().isTrespassing = true; } } }