Hello, I'm testing out Unity Networking and I have a script that sets my player's parent as the Canvas since my spawn points, which are in the canvas, won't make my player spawn there. However, I can't get this SetParent() to sync across games. The script in question is this : Code (CSharp): using UnityEngine; using UnityEngine.Networking; using UnityEngine.UI; public class PlayerController : NetworkBehaviour { void Start () { // Place the Player into the Canvas GameObject.Find("Player(Clone)").GetComponent<Image>().transform.SetParent(GameObject.Find("Canvas").GetComponent<Canvas>().transform); } } Since this is a transform, I added a Network Transform to my player prefab, but it still won't sync... What could be the issue? Thanks!
What you want to do is to sync the parent name in some form of syncVar (string). Then you would setParent on your StartMethod. Personally used this post as reference: http://stackoverflow.com/questions/...bject-as-a-child-for-the-host-and-all-clients
Something like this? Unfortunately, it's still not syncing across games... I'm also getting a warning saying "Trying to send command for object without authority." Code (CSharp): using UnityEngine; using UnityEngine.Networking; using UnityEngine.UI; using System.Collections; public class PlayerController : NetworkBehaviour { [SyncVar] public string parent = "Canvas"; void Start () { CmdSetParent(parent); // Place the Player into the Canvas GameObject.Find("Player(Clone)").GetComponent<Image>().transform.SetParent(GameObject.Find(parent).GetComponent<Canvas>().transform); } [Command] public void CmdSetParent(string newParent) { parent = newParent; } } Thanks! Edit : I apologize if the code is way off... I have almost no experience in Unity Networking.
The objects you are spawning as children. Make sure their network identity is "localPlayerAuthority". And use the NetworkServer.SpawnWithAuthority and not the standard NetworkServer.Spawn. You can only send commands from objects you have authority over.