Ashby Issac fbeac39eb3 Gameplay system changes.
completed prototyping.
Integrated abstraction layer from previous project.
Refactored gameplay code.
Found an issue with drifting and added a quick fix for the same.
Added camera system for chasing player movement.
2026-01-05 19:59:43 +05:30

64 lines
1.7 KiB
C#

using UnityEngine;
using UnityEngine.EventSystems;
public class UIHover : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
{
[SerializeField] private InputType inputType;
[SerializeField] private float maxLerpTimer = 1f;
[SerializeField] private float minInputVal;
[SerializeField] private float maxInputVal;
private InputManager inputManager;
private float lerpTimer = 0f;
private bool canDetectInput = false;
private float currInputVal, targetInputVal;
public void OnPointerDown(PointerEventData eventData)
{
inputManager = inputManager ?? InterfaceManager.Instance?.GetInterfaceInstance<InputManager>();
currInputVal = minInputVal;
targetInputVal = maxInputVal;
canDetectInput = true;
lerpTimer = 0f;
Debug.Log($"OnPointerEnter");
}
public void OnPointerUp(PointerEventData eventData)
{
lerpTimer = 0;
targetInputVal = minInputVal;
canDetectInput = true;
Debug.Log($"OnPointerExit");
// if (lerpTimer < maxLerpTimer)
// {
// lerpTimer = 0;
// canDetectInput = false;
// inputManager.OnInputProvided(inputType, targetInputVal);
// }
// else
// {
// lerpTimer = 0;
// }
}
private void Update()
{
if (!canDetectInput) return;
if (lerpTimer >= maxLerpTimer)
{
lerpTimer = 0;
canDetectInput = false;
return;
}
lerpTimer += Time.deltaTime;
currInputVal = Mathf.Lerp(currInputVal, targetInputVal, lerpTimer);
inputManager.OnInputProvided(inputType, currInputVal);
}
}