39 lines
936 B
C#
39 lines
936 B
C#
using XCEngine;
|
|
|
|
namespace ProjectScripts
|
|
{
|
|
public sealed class MoveProbe : MonoBehaviour
|
|
{
|
|
public float moveSpeed = 2f;
|
|
public float moveRange = 3f;
|
|
|
|
private Vector3 initialPos;
|
|
private float currentOffset;
|
|
private int direction = 1;
|
|
|
|
void Start()
|
|
{
|
|
initialPos = transform.position;
|
|
currentOffset = 0f;
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
currentOffset += moveSpeed * Time.deltaTime * direction;
|
|
|
|
if (currentOffset >= moveRange)
|
|
{
|
|
currentOffset = moveRange;
|
|
direction = -1;
|
|
}
|
|
else if (currentOffset <= 0f)
|
|
{
|
|
currentOffset = 0f;
|
|
direction = 1;
|
|
}
|
|
|
|
float y = initialPos.y + currentOffset;
|
|
transform.position = new Vector3(initialPos.x, y, initialPos.z);
|
|
}
|
|
}
|
|
} |