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