23 lines
552 B
C#
23 lines
552 B
C#
using UnityEngine;
|
|
|
|
public class PlayerController : MonoBehaviour
|
|
{
|
|
private float direction = 1.0f;
|
|
[SerializeField][Range(0.1f, 50f)] private float moveSpeed = 0.5f;
|
|
|
|
private void Update()
|
|
{
|
|
Debug.Log("FPS: " + (1.0f / Time.deltaTime));
|
|
|
|
if (transform.position.z >= 175)
|
|
{
|
|
direction = -direction;
|
|
}else if (transform.position.z <= 10)
|
|
{
|
|
direction = -direction;
|
|
}
|
|
|
|
transform.Translate(0.0f, 0.0f, moveSpeed * direction * Time.deltaTime);
|
|
}
|
|
}
|