TrueSyncBehaviour player ownership
Options
Hi ,
I have a simple question, which solution I couldn't find at the documentation site.
My problem is this error..
https://image.ibb.co/mzbYpk/forum.png
..so, how to set the ownership of GameObject in TrueSync behaviour??
Thanks for any kind of help .
I have a simple question, which solution I couldn't find at the documentation site.
My problem is this error..
https://image.ibb.co/mzbYpk/forum.png
..so, how to set the ownership of GameObject in TrueSync behaviour??
Thanks for any kind of help .
0
Best Answer
-
Afaik you can can only set ownership of the TrueSync behaviour instances, not of gameobjects (TrueSyncManager prefabs aside). You can set the owner f.e. after instantiating with: GetComponent().owner = TSPlayerInfo (get the player you want to give control f.e. via playerid).
As an example:
var player = TrueSyncManager.SyncedInstantiate(playerPrefab);
player.GetComponent< Movement >().owner = TrueSyncManager.Players[1];
instantiates a player prefab and gives player 1 control over the movement script.5
Answers
-
Afaik you can can only set ownership of the TrueSync behaviour instances, not of gameobjects (TrueSyncManager prefabs aside). You can set the owner f.e. after instantiating with: GetComponent().owner = TSPlayerInfo (get the player you want to give control f.e. via playerid).
As an example:
var player = TrueSyncManager.SyncedInstantiate(playerPrefab);
player.GetComponent< Movement >().owner = TrueSyncManager.Players[1];
instantiates a player prefab and gives player 1 control over the movement script.5 -
Yep @blubwage, another thing @Vokyczech is that you can have code that doesn't belong to player, which you can see in the demo "boxes". A TrueSyncBehaviour without owner could easily led to a sync error between multiple instances, so we remove this possibility a long time ago and added that warning message.0
-
@blubwage your solution is working, thank you! And @JeffersonHenrique, thanks for your explanation, it will improve my thinking about the whole ownership thing in the future.
...and sorry for late my late reply, guys, but I hadn't time on programming recently0