SyncedInstantiate problem

Hi,
I am making truesync based game and I have a little problem.. When I am instantiating a gameobject via SyncedInstantiate, the other player don't see the instantiated object.

This is the script for instantiating (values of GameObject, TSVector2 and TSQuaternion in SyncedInstantiate works fine, no need to chech them out):
using UnityEngine; using System.Collections; using TrueSync; public class GameStart : TrueSyncBehaviour { public override void OnSyncedStart() { Spawn(); } public void Spawn(bool reversed){ int loadNumber = PlayerPrefs.GetInt ("choosedLoad"); for (int i = 0; i < PlayerPrefs.GetInt (loadNumber + ".counted"); i++) { GameObject Inst = TrueSyncManager.SyncedInstantiate(Resources.Load("Buildings/Fight/" + PlayerPrefs.GetInt ((loadNumber * 100 + i).ToString () + ".building")) as GameObject, new TSVector2 ((PlayerPrefs.GetFloat ((loadNumber * 100 + i).ToString () + ".posX")), (PlayerPrefs.GetFloat ((loadNumber * 100 + i).ToString () + ".posY"))), TSQuaternion.identity); } } }

Code for joining players into rooms (at different Scene):
https://drive.google.com/open?id=0B31tombwa2THMVZrb1hWdlE2TjQ

Inspector of instantiated prop:
https://drive.google.com/file/d/0B31tombwa2THNXNYdjJaeDRlNFE/view?usp=sharing

Best Answer

Answers

  • Kreso
    Kreso
    edited February 2017
    Hey Vokyczech,

    I don't know what the problem is, but did you make sure what "PlayerPrefs int" is on both clients?
    My suspicion is that it might not have that value as you expect. Might be worth taking a look?
    Specifically this value:
    PlayerPrefs.GetInt ((loadNumber * 100 + i).ToString ()

    Let me know!
  • Kreso,
    I really appreciate your help, but I am afraid PlayerPrefs part isn't the origin of the problem. I changed some scripts since your comment and problem is still there. I built game, and everything worked fine, both clients joined lobby, each client opened Fight scene (synced scene load don't work, but it isn't problem right now) and then instantiated their own building, but enemy building still nowhere :( .

    I made some screenshots, which at best will lead to solve (at Fight scene you can spot green blocks, these blocks are instantiated via TrueSyncManager on each client, so it is indicator of both players presence + in console I have debug of players amount).

    At Matchmaking scene:
    Mountain View

    At Fight scene, where should spawn the other player, but don't:
    Mountain View

    (I will be very grateful for any kind of help, because with this problem I am not able to continue in developing process of the game.)
  • Hey @Vokyczech, if you feel comfortable uploading your project and sending me the link - I'd be willing to check out what might be going on.
  • I really appriciate your help, @Kreso ! What's your email? I will send you link to the project on Google Disk + list of the scripts that have do to something with PUN..