using Unity.Mathematics; using UnityEngine; namespace MAVRIC.GEEKCup { public class MoveFloor : MonoBehaviour { [Range(0f, 10f)] [SerializeField] private float speed = 1f; [Range(0f, 10f)] [SerializeField] private float distance = 1f; [PostNormalize] [SerializeField] private Vector3 direction = Vector3.right; private Vector3 startPos; private void Start() { startPos = transform.position; } private void Update() { if (Vector3.Distance(startPos, transform.position) > distance || Vector3.Distance(startPos, transform.position) < -distance) { direction *= -1; } var speedScaled = speed * Time.deltaTime; transform.Translate(direction.normalized * speedScaled, Space.Self); } } }