using System.Collections; using System.Collections.Generic; using UnityEngine; /* -------------------------------------- Project: Programing assessment Standard: 91906 (AS3.7) v.1 School: Tauranga Boys' College Author: Rauputu Noah Phizacklea Date: August 2024 Unity: 2021.3.18f --------------------------------------- */ public class Boss : MonoBehaviour { public Transform player; // Reference to the player's transform public bool isFlipped = false; // Flag to check if the boss is flipped // Method to make the boss look at the player public void LookAtPlayer() { // Create a Vector3 to hold the flipped scale Vector3 flipped = transform.localScale; flipped.z *= -1f; // Flip the z-axis scale to change the direction // Check if the boss needs to flip based on player's position if (transform.position.x > player.position.x && isFlipped) { // If the boss is on the right side of the player but currently flipped, flip back transform.localScale = flipped; transform.Rotate(0f, 180f, 0f); // Rotate the boss to face the player isFlipped = false; } else if (transform.position.x < player.position.x && !isFlipped) { // If the boss is on the left side of the player but not flipped, flip transform.localScale = flipped; transform.Rotate(0f, 180f, 0f); // Rotate the boss to face the player isFlipped = true; } } }