29 lines
657 B
C#
29 lines
657 B
C#
using UnityEngine;
|
|
|
|
namespace Artngame.TEM
|
|
{
|
|
public class MoveTarget : MonoBehaviour
|
|
{
|
|
private float speed = 55f;
|
|
|
|
private Vector3 goal;
|
|
|
|
private float mapHalfSize = 500f;
|
|
|
|
private void Start()
|
|
{
|
|
goal = new Vector3(Random.Range(0f - mapHalfSize, mapHalfSize), 0f, Random.Range(0f - mapHalfSize, mapHalfSize));
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
base.transform.LookAt(goal);
|
|
base.transform.Translate(Vector3.forward * speed * Time.deltaTime);
|
|
if ((base.transform.position - goal).sqrMagnitude < 2f)
|
|
{
|
|
goal = new Vector3(Random.Range(0f - mapHalfSize, mapHalfSize), 0f, Random.Range(0f - mapHalfSize, mapHalfSize));
|
|
}
|
|
}
|
|
}
|
|
}
|