agent removed
This commit is contained in:
parent
ef859cbd0d
commit
2bcee7add8
1 changed files with 9 additions and 6 deletions
|
@ -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]
|
||||
|
|
Reference in a new issue