Files
Inter-Face-Off/Assets/Scripts/World/PlayerController.cs
2026-01-15 18:49:00 +00:00

31 lines
857 B
C#

using UnityEngine;
using UnityEngine.Serialization;
namespace InterfaceOff.WorldScene
{
public class PlayerController : MonoBehaviour
{
private static PlayerController Instance;
[field: SerializeField] private Transform[] LerpPositions;
private float LerpValue;
public static void SetPos(Vector3 pos)
{
Instance.transform.position = pos;
}
private void Update()
{
LerpValue = (LerpValue + Time.deltaTime) % 3f;
int section = Mathf.FloorToInt(LerpValue);
float sectionLerp = LerpValue % 1f;
Vector3 a = LerpPositions[section + 0].position;
Vector3 b = LerpPositions[section + 1].position;
transform.position = Vector3.Lerp(a, b, sectionLerp);
}
}
}