feat(project): refresh sample scenes and Nahida assets
This commit is contained in:
39
project/Assets/Scripts/MoveProbe.cs
Normal file
39
project/Assets/Scripts/MoveProbe.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user