void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag == "Player") { TestControllerForThirdPersonCamera script = player.GetComponent <TestControllerForThirdPersonCamera>(); script.WinGame(); } }
// Update is called once per frame void Update() { switch (state) { case State.patrol: if (waypoints.Length > 1) { animator.SetBool("playerFound", false); } else { animator.SetBool("Idle", true); } if (agent.remainingDistance < 1f && agent.pathPending == false) { if (currWaypoint == waypoints.Length - 1) { currWaypoint = 0; } else { currWaypoint += 1; } } agent.SetDestination(waypoints[currWaypoint].transform.position); findPlayer(); break; case State.chase: if (agent.remainingDistance < 1f && agent.pathPending == false) { TestControllerForThirdPersonCamera script = player.GetComponent <TestControllerForThirdPersonCamera>(); script.LoseGame(); } agent.SetDestination(player.transform.position); animator.SetBool("Idle", false); animator.SetBool("playerFound", true); findPlayer(); break; case State.qtevent: break; case State.investigateSound: // Debug.Log("Investigating Sound " + investigationLength); if (agent.remainingDistance < 1f && agent.pathPending == false) { animator.SetBool("Idle", true); } agent.SetDestination(soundLocation); investigationLength -= Time.deltaTime; if (investigationLength <= 0.0f) { Debug.Log("Got bored of sound, going back to patrolling"); state = State.patrol; animator.SetBool("Idle", false); } findPlayer(); break; } }