Made player "move"
This commit is contained in:
@@ -1,14 +1,31 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user