- Home /
Question by
yilvonmotz · Dec 12, 2018 at 01:30 PM ·
networkingmultiplayeranswers
Networking, SyncVar makes transform sync not work,after setting a SyncVar, transform sync doesn't work
Hi, i ve been trying to learn about networking in unity and stumbled a thing i don't understand (actually iam stubling about a lot of things related to that topic :/ )
I did a simple setup as shown below
i start the build as host and the other one in the editor as client. The players shows up as a 2d circle , 2 circles after starting both. And now what is strange to me. When i have a SyncVar in the code movements i do on the host doesn't show on client. When not having a SyncVar it does. Client moves show up in both.
maybe you can help me understand this
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Networking; using UnityEngine.UI;
public class PlayerBehaviour : NetworkBehaviour {
[SyncVar]
public int blubb;
//[SyncVar]
//public int ColorCode;
private string localPlayerName;
public Text PlayerText;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (!isLocalPlayer)
{
return;
}
transform.Translate(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"), 0f);
}
}
unitysetup.png
(151.7 kB)
Comment