38 lines
961 B
C#
38 lines
961 B
C#
using TMPro;
|
|
using UnityEngine;
|
|
|
|
public class PopUp : MonoBehaviour
|
|
{
|
|
public TMP_Text Text;
|
|
public float DestroyTime = 5;
|
|
|
|
float timeSinceCreation;
|
|
|
|
Vector3 offset;
|
|
bool dropDown;
|
|
|
|
private void Start()
|
|
{
|
|
timeSinceCreation = Time.time;
|
|
offset.y = -100;
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (!Player.Instance) return;
|
|
|
|
if (dropDown)
|
|
offset.y = Mathf.Lerp(offset.y, -100, Time.deltaTime / 2f);
|
|
else
|
|
offset.y = Mathf.Lerp(offset.y, 0, Time.deltaTime * 5f);
|
|
|
|
this.transform.position = Vector3.Lerp(this.transform.position, Player.Instance.Camera.transform.position + (Player.Instance.Camera.transform.forward * 5) + offset, Time.deltaTime * 10f);
|
|
this.transform.rotation = Quaternion.Lerp(this.transform.rotation, Player.Instance.Camera.transform.rotation, Time.deltaTime * 10f);
|
|
|
|
if (Time.time > timeSinceCreation + (DestroyTime - 1))
|
|
dropDown = true;
|
|
if (Time.time > timeSinceCreation + DestroyTime)
|
|
Destroy(this.gameObject);
|
|
}
|
|
}
|