Realised we don't actually need portals
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace InterfaceOff.WorldScene
|
||||
{
|
||||
@@ -7,24 +7,20 @@ namespace InterfaceOff.WorldScene
|
||||
{
|
||||
private static PlayerController Instance;
|
||||
|
||||
[field: SerializeField] private float PlayerSpeed { get; set; }
|
||||
[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;
|
||||
|
||||
LerpValue += PlayerSpeed / Vector3.Distance(a, b) * Time.deltaTime;
|
||||
LerpValue %= LerpPositions.Length - 1; // Makes lerp value wrap around
|
||||
|
||||
float sectionLerp = Math.Clamp(LerpValue, section, section + 1) - section;
|
||||
transform.position = Vector3.Lerp(a, b, sectionLerp);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user