Different prefab for Owner-Creator/Non-Owner (not server/client)

Hi All!

I have created a pool class from IPrefabPool outlined in the Bolt Docs.
I have added the default code to the three methods, and this is working great.

I did this to be able to create a different prefab by Owner-Creator/NotOwner (instead of server/client).
The player characters are created on each instance, not exclusively on the server.

So each instance has a call like:
var character = BoltNetwork.Instantiate(BoltPrefabs.MyCharacter);

Is there a way to tell, in the Instantiate method of my custom prefab pool, if it is the same game instance that called Instantiate vs Bolt calling it when another instance creates the bolt prefab?

Example:
Say I have a MyCharacter prefab for the players character, and a MyREMOTECharacter prefab for the connected players on that same game instance.

Server - BoltNetwork.Instantiate(BoltPrefabs.MyCharacter); - in prefab pool - creates BoltPrefabs.MyCharacter
Client A - in prefab pool - creates BoltPrefabs.MyREMOTECharacter for server character
Client B - in prefab pool - creates BoltPrefabs.MyREMOTECharacter for server character

-----
Client A - BoltNetwork.Instantiate(BoltPrefabs.MyCharacter); - in prefab pool - creates BoltPrefabs.MyCharacter
Server - in prefab pool - creates BoltPrefabs.MyREMOTECharacter for client A character
Client B - in prefab pool - creates BoltPrefabs.MyREMOTECharacter for client A character
-----
Client B - BoltNetwork.Instantiate(BoltPrefabs.MyCharacter); - in prefab pool - creates BoltPrefabs.MyCharacter
Client A - in prefab pool - creates BoltPrefabs.MyREMOTECharacter for client B character
Server - in prefab pool - creates BoltPrefabs.MyREMOTECharacter for client B character


Is that possible? Is there something I can check to see if this game instance was the one that called BoltNwork.Instanciate ?

Thanks!

Best Answer

Answers

  • In Slack there is a wip doc that details Bolt pooling, you can control this kind of thing there.
  • Thanks for the reply.
    I had used that doc initially to create the pooling class.
    I had found it originally from this post:
    http://forum.photonengine.com/discussion/10630/different-prefabs-for-local-and-remote-player

    The doc on Slack is the same google doc, correct?

    What I don't know from looking at that is what I can check to see what is calling the the PrefabPool Instantiate method.

    I can check BoltNetwork.isClient or isServer, but what I want to know is basically isOwner or not.

    Each player's game instantiates their own prefab. Inside the pool, I would like to know the difference when the player is calling it, or when Bolt is calling it on the other instances because the initial player called it.


    So Player A calls BoltNetwork.Instantiate(prefab). Player A can be client or server - doesn't matter.

    Inside the PrefabPool - i check that it is this player instantiating it, and create that prefab

    In Players B, C, and D - they are creating Player A's character - inside the PrefabPool, I check that this is NOT the instance that created it, and create a different prefab.

    Is this possible? Is there someway to know that I am in that pool because I received the notification that another instance created a Bolt prefab? I am hoping it is something simple I am missing.

    Thanks!

  • Awesome! Thank you!
    In the meantime I will be using the player state code to update the GameObject in the Attached method.
Sign In or Register to comment.