MiniGames/Assets/Scripts/SkyWalker/Skywalker_MovingPlatform.cs
2025-09-06 23:30:06 +05:00

26 lines
574 B
C#

using UnityEngine;
public class Skywalker_MovingPlatform : MonoBehaviour
{
public float speed = 2f;
public float distance = 3f;
private Vector3 startPos;
public bool reverse;
void Start()
{
startPos = transform.position;
}
void Update()
{
if (!reverse)
{
transform.position = startPos + Vector3.down * Mathf.PingPong(Time.time * speed, distance);
}
else
{
transform.position = startPos + Vector3.up * Mathf.PingPong(Time.time * speed, distance);
}
}
}