Added Unity events to the Slotting Items, the eyes react fine but sometimes they fuck up. gonna check that out later.
42 lines
1.1 KiB
C#
42 lines
1.1 KiB
C#
using UnityEngine;
|
|
|
|
public class Distancemeasurer : MonoBehaviour
|
|
{
|
|
public float playerDistanceFar;
|
|
public float playerDistanceClose;
|
|
public BirdEyesBehavior birdEyes;
|
|
private Vector2 eyesPosition;
|
|
private Vector2 playerPosition;
|
|
private float distance;
|
|
private GameObject player;
|
|
|
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
|
void Start()
|
|
{
|
|
eyesPosition = transform.position;
|
|
player = GameObject.FindWithTag("Player");
|
|
playerPosition = player.transform.position;
|
|
distance = Vector2.Distance(eyesPosition, playerPosition);
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
playerPosition = player.transform.position;
|
|
distance = Vector2.Distance(eyesPosition, playerPosition);
|
|
Debug.Log("Distance to player: " + distance);
|
|
if (distance > playerDistanceFar)
|
|
{
|
|
birdEyes.NoItem();
|
|
} else if (distance > playerDistanceClose)
|
|
{
|
|
birdEyes.IncorrectItem();
|
|
} else
|
|
{
|
|
birdEyes.CorrectItem();
|
|
}
|
|
}
|
|
|
|
|
|
}
|