Started on the sound generator section of the soundbird puzzle, plus organized folders.
36 lines
1.0 KiB
C#
36 lines
1.0 KiB
C#
using UnityEngine;
|
|
|
|
public class Distancemeasurer : MonoBehaviour
|
|
{
|
|
public float playerToPlaceDistance;
|
|
public BirdEyesBehavior birdEyes;
|
|
private Vector2 placePosition;
|
|
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()
|
|
{
|
|
placePosition = transform.position;
|
|
player = GameObject.FindWithTag("Player");
|
|
playerPosition = player.transform.position;
|
|
distance = Vector2.Distance(placePosition, playerPosition);
|
|
}
|
|
|
|
// Update is called once per frame
|
|
// TODO: Make this less expensive by not doing it every frame
|
|
void Update()
|
|
{
|
|
playerPosition = player.transform.position;
|
|
distance = Vector2.Distance(placePosition, playerPosition);
|
|
//Debug.Log("Distance to player: " + distance);
|
|
if (distance > playerToPlaceDistance && birdEyes.correctItemIsIn == true)
|
|
{
|
|
birdEyes.BirdReveal();
|
|
}
|
|
}
|
|
|
|
|
|
}
|