You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
551 B
29 lines
551 B
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class NPCMove : MonoBehaviour
|
|
{
|
|
public Vector3 start, end;
|
|
public float speed = 2f;
|
|
|
|
void Start()
|
|
{
|
|
start = this.transform.position;
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
transform.position = Vector3.MoveTowards(transform.position, end, Time.deltaTime * speed);
|
|
|
|
|
|
if (Vector3.Distance(transform.position, end) <= 1f)
|
|
{
|
|
transform.position = start;
|
|
}
|
|
}
|
|
|
|
|
|
}
|