playMaker

Author Topic: n00b question - Creating GameObjects in multiplayer / Photon  (Read 1993 times)

jess84

  • Hero Member
  • *****
  • Posts: 515
n00b question - Creating GameObjects in multiplayer / Photon
« on: August 16, 2013, 12:40:37 PM »
So I currently have the photon stuff working, and can get multiple people into the same room, and have them all in sync.

I now want to create some collectable game objects. (initially cubes)

I'm using Photon Instantiate to create them, and that's fine for the first person who enters the room - however all subsequent players also spawn a set of cubes too. So I'm ending up with multiple cubes when there should just be the 1 set.

Any ideas how to approach this?

Red

  • Hero Member
  • *****
  • Posts: 563
Re: n00b question - Creating GameObjects in multiplayer / Photon
« Reply #1 on: August 16, 2013, 07:08:34 PM »
Though I'm not very familiar with how Photon does it's thing, I've played around (to some degree of success) with the native networking stuff... so, what I'm going to talk about might not be exactly what you're looking for.

But, If you have all instances spawning the same item, is it that you're having the event that calls this set of actions be a global event that is being sent through the entire system?

If so, isolating it might be a thing to consider... So, say player 1 makes the cube appear with a FSM that's isolated (and not using global broadcasts) then having that be instantiated from that instance of the game could be one way to approach it... This would be like keeping the system only call-able by the person activating it (so, say player 1 opens a chest, then player 1's instance of the game spawns the items and the new items information is sent to the other instances of the game.)

Past that, if this is a system where there is a dedicated host and the rest are only joining that game, another possible way could be having that whenever anyone (host or joined) opens an object, it'd send a message through the networking to the host for the host to spawn the item you want.

Though, to be honest this IS without in-depth knowledge of how Photon does it's thing... so, this is more a shot from the hip to be completely honest.

Past that, if you have a screenshot of the system available, that could help narrow down where this issue is coming from... so, if you have any i'm sure it'd help a little bit to see them.

jess84

  • Hero Member
  • *****
  • Posts: 515
Re: n00b question - Creating GameObjects in multiplayer / Photon
« Reply #2 on: August 17, 2013, 07:41:48 AM »
Thanks, that's really helpful. For now, I've gone with a check to see if the player is the server, if they are, I'm instantiating the objects.

One step at a time.... next up, removing them on all clients when *someone* picks up one  :)