// Camera kills player (via laser) if detected, otherwise it scans the scene void FixedUpdate() { if (vC.getDetected() == true || playerSeen == true) { playerSeen = true; if (deathDelayTimer == 0f) { lb.LaserOn(sceneManager.instance.target); movementManager.instance.canMove = false; } else if (deathDelayTimer > deathTriggerLimit) { gameManager.death(); } deathDelayTimer += Time.fixedDeltaTime; } else { angle.transform.eulerAngles = new Vector3(q.x, q.y + rotateRangeDeg * Mathf.Sin(18 * Time.time * (2 * Mathf.PI) / 180), q.z); } }
void FixedUpdate() { if (vC.getDetected() == true || playerSeen == true) { playerSeen = true; rb.velocity = Vector3.zero; rb.angularVelocity = Vector3.zero; anim.SetFloat("Speed", 0f); transform.LookAt(target.transform.position); if (deathDelayTimer == 0f) { audioSrc.clip = audioArr [0]; //sound clip of laser agent.isStopped = true; //agent.enabled = false; lb.LaserOn(target); movementManager.instance.canMove = false; } else if (deathDelayTimer > deathTriggerLimit) { gameManager.death(); } deathDelayTimer += Time.fixedDeltaTime; } else { closestDog = sceneManager.getClosestActiveDog(gameObject.transform.position); //If there is a dog nearby the Android follows the dog, otherwise it navigates along its set waypoints if (closestDog != null) { agent.destination = closestDog.transform.position; rb.velocity = rb.velocity.normalized / 1.5f; } else { //Android slows down and then stops completely as it approaches its waypoint if (agent.remainingDistance > 2f) { rb.velocity = rb.velocity.normalized / 2f; waypointUpdated = false; } else if (agent.remainingDistance <= 2f && agent.remainingDistance > 0.2f) { rb.velocity = rb.velocity.normalized * Mathf.Min(agent.remainingDistance / 4 + 0.1f, 1); } else if (agent.remainingDistance <= 0.2f && waypointUpdated == false) { Debug.Log(agent.name + " is too close to destination!"); rb.velocity = Vector3.zero; rb.angularVelocity = Vector3.zero; GotoNextWayPoint(); waypointUpdated = true; } } anim.SetFloat("Speed", rb.velocity.magnitude); // set our animator's float parameter 'Speed' equal to the vertical input axis } }