Question by
Jordansweeto_ · Feb 20, 2020 at 02:08 PM ·
unity 5playernetworkenemy aifollow player
Enemy doesn't follow player clone,Enemy doesn't follow the player clone
Hi! I have a problem in my game. I used this script for the enemy:
using UnityEngine;
using System.Collections;
public class Enemy : MonoBehaviour {
private NavMeshAgent Mob;
public GameObject Player;
public float MobDistanceRun = 4.0f;
// Use this for initialization
void Start () {
Mob = GetComponent<NavMeshAgent>();
}
// Update is called once per frame
void Update () {
float distance = Vector3.Distance(transform.position, Player.transform.position);
if(distance < MobDistanceRun)
{
Vector3 dirToPlayer = transform.position - Player.transform.position;
Vector3 newPos = transform.position - dirToPlayer;
Mob.SetDestination(newPos);
}
}
}
My problem is that when i start a server the enemy doesn't follow the player clone. I'd like to do that he can follow all the players. Can you help me?
Comment
when i start a server? Then who is the player? A client? Ho you define/assign it to the variable?