agent removed

This commit is contained in:
Steven 2017-09-27 23:56:52 -05:00
parent ef859cbd0d
commit 2bcee7add8

View file

@ -4,7 +4,6 @@ using UnityEngine.AI;
public class SimpleNPCBehavior : Photon.PunBehaviour
{
private NavMeshAgent agent;
private bool setTarget = true;
enum State {
@ -13,9 +12,8 @@ public class SimpleNPCBehavior : Photon.PunBehaviour
talking
};
void Start()
void Start()
{
agent = GetComponent<NavMeshAgent>();
//agent = gameObject.AddComponent<NavMeshAgent>();
if (PhotonNetwork.isMasterClient) {
photonView.RPC("TeleportToTarget", PhotonTargets.All, GetRandomLocation());
@ -36,6 +34,11 @@ public class SimpleNPCBehavior : Photon.PunBehaviour
}
}
NavMeshAgent GetAgent()
{
return GetComponent<NavMeshAgent>();
}
IEnumerator UpdateDestination()
{
yield return new WaitForSeconds(Random.Range(0.1f, 10.0f));
@ -59,14 +62,14 @@ public class SimpleNPCBehavior : Photon.PunBehaviour
[PunRPC]
void SetTarget(Vector3 target)
{
agent.destination = target;
GetAgent().destination = target;
}
[PunRPC]
void TeleportToTarget(Vector3 target)
{
agent.Warp(target);
agent.destination = target;
GetAgent().Warp(target);
GetAgent().destination = target;
}
[PunRPC]