You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.1 KiB

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);
}
}