26 lines
574 B
C#
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);
|
|
}
|
|
|
|
}
|
|
} |