Query for how to set up my network objects
The whole answer can be found below.
Try Our
Documentation
Please check if you can find an answer in our extensive documentation on Fusion.
Join Us
on Discord
Meet and talk to our staff and the entire Photon-Community via Discord.
Read More on
Stack Overflow
Find more information on Stack Overflow (for Circle members only).
Query for how to set up my network objects
Shreyas
2022-01-25 02:55:30
I am trying to build a chess game and I want to network this over the internet using fusion. My project is setup using "Shared mode".
I use this code to instantiate chess pieces when players start the game-
Runner.Spawn(defaultPiecePrefab, spawnPos, spawnRot)
However with this method I am seeing that the player who has spawned the pieces get the authority to move the pieces while the other player doesn't.
I want the chess pieces to be able to be controlled and moved by any player in the room. (I dont want them to be under the state authority of any player). This is needed because even if one player leaves the room and another one comes in, the pieces should not get destroyed and the new player should be able to control the pieces.
I tried this method
Object.RequestStateAuthority();
to request state authority for the black pieces. However this takes time to transfer the authority and I also dont want any specific player to be the owner the pieces as mentioned above.
Basically I want these chess pieces to be similar to the scene objects in PUN.
So the question is, is there any equivalent call to "PhotonNetwork.InstantiateRoomObject" in Fusion. If not what is the best way to Spawn chess pieces so that they are totally player independent. Please let me know. Thanks!
Comments
As far as I know, objects in Fusion don't get destroyed automatically, when the controller leaves. So there is not really a need for InstantiateRoomObject. Let the host spawn an object and I think you are more or less done.
Will move this from the PUN forum to the Fusion one.
Thanks for the reply Tobias. If the only available option for spawning is Runner.Spawn, how do I instantiate my network objects(chess pieces)? I want the network objects to be picked up and moved by either player.
There is a possibility of transferring state authority from one player to the other but in my case the state authority takes several seconds to transfer to the other player so he may grab the object and move it. Until then if the user attempts to grab the object, it snaps back into place. Any solution for this issue?
in my case the state authority takes several seconds to transfer to the other player
This is surprising. How bad is that lag?!
You can put a NB on each of the pieces and simply place them in the scene. I guess you should even be able to create a board prefab with the pieces being individual parts in it.
I will ask a colleague to chime in about picking pieces and avoiding lag.
Back to top