Multiplayer zombie game. Problem with zombies.

So. I am making a zombie game. And now I’ve found a problem with my zombies when i tested my game at the first time with zombies on(with another player playing with me). So the zombies spawned but! When i started the server zombies spawned and began to attack me.Looking at my friends screen the zombies weren’t attacking me. They where attacking my friend.

I know this is pretty wierd. I’ve attached network view to my zombies.
So how do so the zombies aren’t local?
(The zombies are just cubes)

//The zombie spawner

using UnityEngine;
using System.Collections;

public class ZombieSpawner : MonoBehaviour
  // Spawn location
  public Vector3 spawnLocation =;
  // Spawn radius (Gives a bit more randomness factor to the spawn location)
  public float spawnRadius = 1.0f;
  // Spawn timer (seconds)
  public float spawnTimer = 5.0f;
  private float spawnTimeRemaining = 5.0f;

  // The zombie to spawn
  public GameObject zombiePrefab = null;

  void Awake()
    spawnTimeRemaining = spawnTimer;

  void FixedUpdate()
    spawnTimeRemaining -= Time.deltaTime;

    if (spawnTimeRemaining < 0.0f)
      Vector2 circlePosition = Random.insideUnitCircle * spawnRadius;
      GameObject.Instantiate(zombiePrefab, spawnLocation + new Vector3(circlePosition.x, 0.0f, circlePosition.y), Quaternion.identity);

      spawnTimeRemaining = spawnTimer;

The zombie AI.

//zombie AI

var target : Transform; //the enemy's target
var moveSpeed = 3; //move speed
var rotationSpeed = 3; //speed of turning
var attackThreshold = 1.5; // distance within which to attack
var chaseThreshold = 10; // distance within which to start chasing
var giveUpThreshold = 20; // distance beyond which AI gives up
var attackRepeatTime = 1; // delay between attacks when within range

private var chasing = false;
private var attackTime = Time.time;

var myTransform : Transform; //current transform data of this enemy

function Awake()
    myTransform = transform; //cache transform data for easy access/preformance 

function Start()
     target = GameObject.FindWithTag("Player").transform; //target the player

function Update () {

    // check distance to target every frame:
    var distance = (target.position - myTransform.position).magnitude;

    if (chasing) {

        //rotate to look at the player
        myTransform.rotation = Quaternion.Slerp(myTransform.rotation,
        Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed*Time.deltaTime);

        //move towards the player
        myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime;

        // give up, if too far away from target:
        if (distance > giveUpThreshold) {
            chasing = false;

        // attack, if close enough, and if time is OK:
        if (distance < attackThreshold && Time.time > attackRepeatTime) {

            // Attack! (call whatever attack function you like here)
        if (distance < attackThreshold) {
        //stop when close enough

            attackTime = Time.time+ attackRepeatTime;

      else {
        // not currently chasing.

        // start chasing if target comes close enough
        if (distance < chaseThreshold) {
            chasing = true;


function OnTriggerEnter (other: Collider) {
if (other.gameObject.CompareTag("Bullet")){

Sorry for the long post :S

Thanks. :smiley:

Try not to use different coding language, use this to convert the codes. Also the problem is within your multiplayer script, not the Zombie AI or Zombie Spawner scripts.

that does the language have to do with anything? Listen I can´t say it for sure … but I think you have 2 problem… first I do not think your script is design for more then one target… second your script is probably running on your server and your clien at the same time … you need to disable the script when it is run on the client side of the program