2

I'm trying to check if the player isLocalPlayer but it's just returning false every time. I have a lobby system where two to four players can join and connect on a network, they then spawn into the game but when I control one player it affects the others.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Mirror;

public class Player : Mirror.NetworkBehaviour
{
    void Start()
    {
        if(isLocalPlayer)
        {
            Debug.Log("IN LOCAL PLAYER!!!");
        }
        else{
            Debug.Log("NOT LOCAL PLAYER!!!");
        }
    }

enter image description here

This player script is attched to the player prefab and I have it referenced on the NetworkManager.

Unity version 2021.3.5f1

I'd appreciate any help!

Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36
Leanne
  • 77
  • 9
  • How are you spawning the player prefab? Is it spawned locally or from the server? – JDormer Jul 24 '22 at 21:13
  • @JDormer I am spawning the players in when the Server is ready. In the `OnStartServer` method, I am checking if the server is readied and then it calls the `SpawnPlayer` method. And the `SpawnPlayer` method has this at the top: `[Server]` – Leanne Jul 26 '22 at 09:05
  • Hi, I'm still having this problem, is there any fix for this I'm quite stuck – Leanne Jul 30 '22 at 14:26

0 Answers0