Hurt thingy
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System.Collections;
|
||||
using JetBrains.Annotations;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine;
|
||||
@@ -6,7 +7,9 @@ namespace InterfaceOff.WorldScene
|
||||
{
|
||||
public class LifeThingTrackerThing : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject HurtOverlay;
|
||||
[SerializeField] private Slider SliderThing;
|
||||
|
||||
private Rigidbody body;
|
||||
|
||||
private void Awake()
|
||||
@@ -18,11 +21,13 @@ namespace InterfaceOff.WorldScene
|
||||
{
|
||||
Vector3 pos = transform.localPosition;
|
||||
pos.y = Mathf.Clamp(pos.y, 0, 10);
|
||||
transform.localPosition = pos;
|
||||
|
||||
if (pos.y == 0.0f)
|
||||
if (Mathf.Approximately(pos.y, 0.0f))
|
||||
{
|
||||
StartCoroutine(routine: DisplayHurtOverlay());
|
||||
|
||||
body.velocity = Vector3.zero;
|
||||
pos.y = 10.0f;
|
||||
}
|
||||
|
||||
if (Mathf.Approximately(pos.y, 10.0f))
|
||||
@@ -30,6 +35,7 @@ namespace InterfaceOff.WorldScene
|
||||
body.velocity = Vector3.zero;
|
||||
}
|
||||
|
||||
transform.localPosition = pos;
|
||||
SliderThing.value = pos.y;
|
||||
}
|
||||
|
||||
@@ -38,5 +44,12 @@ namespace InterfaceOff.WorldScene
|
||||
Vector3 vel = body.velocity;
|
||||
body.AddForce(Vector3.up * 500f, ForceMode.Force);
|
||||
}
|
||||
|
||||
private IEnumerator DisplayHurtOverlay()
|
||||
{
|
||||
HurtOverlay.SetActive(true);
|
||||
yield return new WaitForSecondsRealtime(time: 0.1f);
|
||||
HurtOverlay.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user