Added life tracker thing
This commit is contained in:
42
Assets/Scripts/LifeThingTrackerThing.cs
Normal file
42
Assets/Scripts/LifeThingTrackerThing.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using JetBrains.Annotations;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine;
|
||||
|
||||
namespace InterfaceOff.WorldScene
|
||||
{
|
||||
public class LifeThingTrackerThing : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Slider SliderThing;
|
||||
private Rigidbody body;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
body = GetComponent<Rigidbody>();
|
||||
}
|
||||
|
||||
void LateUpdate()
|
||||
{
|
||||
Vector3 pos = transform.localPosition;
|
||||
pos.y = Mathf.Clamp(pos.y, 0, 10);
|
||||
transform.localPosition = pos;
|
||||
|
||||
if (pos.y == 0.0f)
|
||||
{
|
||||
body.velocity = Vector3.zero;
|
||||
}
|
||||
|
||||
if (Mathf.Approximately(pos.y, 10.0f))
|
||||
{
|
||||
body.velocity = Vector3.zero;
|
||||
}
|
||||
|
||||
SliderThing.value = pos.y;
|
||||
}
|
||||
|
||||
[UsedImplicitly] public void AddForceUp()
|
||||
{
|
||||
Vector3 vel = body.velocity;
|
||||
body.AddForce(Vector3.up * 500f, ForceMode.Force);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/LifeThingTrackerThing.cs.meta
Normal file
11
Assets/Scripts/LifeThingTrackerThing.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d84633c3f717e0d4f834bb2514e64c35
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user