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.

50 lines
1.2 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class Catch : MonoBehaviour
{
public GameObject Player;
public Vector3[] target;
public GameObject target1;
public Vector3 target2;
public int flag = 0;
// Start is called before the first frame update
void Start()
{
//Player = GameObject.FindWithTag("Player");
}
// Update is called once per frame
void Update()
{
NavMeshAgent agent = GetComponent<NavMeshAgent>();
if(Player == null) {
if(flag == 0) {
agent.destination = target1.transform.position;
if(!agent.pathPending && agent.remainingDistance < 0.1f) {
flag = 1;
}
//if (agent.pathPending) { flag = 1; }
}
else
{
agent.destination = target2;
if (!agent.pathPending && agent.remainingDistance < 0.1f)
{
flag = 0;
}
}
}
else
{
agent.destination = Player.transform.position;
}
}
}