Hello.
I have this code, just to test out the multiplayer system.
using UnityEngine;
using System.Collections;
using UnityEngine.Networking;
public class CC : NetworkBehaviour {
public int speed;
void Update () {
if(!isLocalPlayer){
return;
}
if(Input.GetKey(KeyCode.W)){
transform.Translate(Vector2.up * speed * Time.deltaTime);
}
if(Input.GetKey(KeyCode.S)){
transform.Translate(Vector2.up * -speed * Time.deltaTime);
}
if(Input.GetKey(KeyCode.D)){
transform.Translate(Vector2.right * speed * Time.deltaTime);
}
if(Input.GetKey(KeyCode.A)){
transform.Translate(Vector2.right * -speed * Time.deltaTime);
}
}
}
It just moves a cube about.
I then have a network manager, with these settings:
and my cube prefab has a Network Transform component with these settings:
My problem is that the positions are only correct on the connected client. So the host client’s cube updates on the connected client, but the connected’s cube doesn’t update on the hosts client.
Any help? I’m new to networking.