Juan Francisco Patino
Juan Francisco Patino

Reputation: 83

Networking Movement not working

I am making a multiplayer scene for my dodgeball game and once I have a host and a client running, it spazzes and forces me to control both the host and the client in one window. Here is what I mean:enter image description here

This is my code managing the network:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
public class Script4Network : NetworkBehaviour
{

// Use this for initialization
void Start() {

}

void Update()
{
    if (!isLocalPlayer)
    {

      return;

    }
}
}

It might have something to do with my lack of understanding LocalAuthority.

Upvotes: 0

Views: 69

Answers (1)

Muhammad Faizan Khan
Muhammad Faizan Khan

Reputation: 10571

You should use isLocalPlayer in Update

// Update is called once per frame
void Update()
{
    if (!isLocalPlayer)
    {
      return;
    }

    if(lives == 0)
    {
        SceneManager.LoadScene("Lose");

    }



    livesText.text = "Lives: " + lives;
}

Upvotes: 1

Related Questions