1
votes

Hello everyone!

I'm relatively new to Unity and currently working around new game project using UNET. I have stuck for a few days with this problem: how I can syncronize existing (not spawned) scene objects in Unity?

I have object named "background" - it's a sprite. When server loads map it changes background's transform scale. All I want to do is to sync it with newly connected clients.

Documentation here says that it should be done automaticlly if object has NetworkIndentity and NetworkTransform components. But it doesn't work for me! https://docs.unity3d.com/Manual/UNetSceneObjects.html

Here is the simplified project: http://prntscr.com/csxoqd I have sprite with scale 40;40. Then in OnServerStart I change it to 100;100 - on the host or server only it works great!

using UnityEngine;
using System.Collections;
using UnityEngine.Networking;

public class NewBehaviourScript : NetworkBehaviour 
{
    // Use this for initialization
    public  override void OnStartServer()
    {
        this.transform.localScale = new Vector3(100, 100, 1);
    }

    // Update is called once per frame
    void Update () {

    }
}

But on client side anything happens. I tried adding NetworkServer.SpawnObjects(); inside this method. Doesn't work.

Any suggestions?

1

1 Answers

0
votes

I'm afraid transform.scale synchronization is still not supported by UNET. It wasn't 1 year ago and it still is now :(

But luckily, you can workaround this problem by using [SyncVar attribute].