holopy3/Assets/Scripts/DigiRonaAgent.cs

38 lines
781 B
C#
Raw Normal View History

2020-12-10 14:25:12 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.PlayerLoop;
public class DigiRonaAgent : MonoBehaviour
{
private NavMeshAgent agent;
private GameObject player;
// Use this for initialization
void Start()
{
agent = GetComponent<NavMeshAgent>();
agent.isStopped = false;
}
private void Update()
{
agent.destination = GameObject.FindWithTag("PlayerBody").transform.position;
if (Input.GetKeyDown("space"))
{
agent.isStopped = !agent.isStopped;
}
}
public void MoveToLocation(Vector3 targetPoint)
{
agent.destination = targetPoint;
agent.isStopped = false;
}
}