using System; using System.Collections; using UnityEngine; public class BearIsAwake : MonoBehaviour { public Transform Penguin; private void Start() { BearAwareness.HasWokenUp += IsAwake; } public void IsAwake(float time) { StartCoroutine(SleepIsOver(time)); } IEnumerator SleepIsOver(float time) { yield return new WaitForSeconds(time); Vector3 direction = Penguin.position - transform.position; float distance = direction.magnitude; direction.Normalize(); // Wichtig: Raycast braucht eine normierte Richtung if (Physics.Raycast(transform.position, direction, out RaycastHit hit, distance)) { Debug.Log("Getroffen: " + hit.collider.name); if (hit.collider.name == "StandUpCollider") { Debug.Log("Your Dead!"); } else { Debug.Log("What?"); } } Debug.DrawLine(transform.position, Penguin.position, Color.red, 10f); } }