playMaker

Author Topic: Photon - Assigning a player type one by one  (Read 1249 times)

DJ_HAXX0RZ

  • Playmaker Newbie
  • *
  • Posts: 1
Photon - Assigning a player type one by one
« on: April 26, 2014, 01:53:20 AM »
I've been stuck in my game using Photon and Playmaker. I copied the Photon DemoWorker Sample over to my game.

Here's what I want:
The game is 4 players, and I want to assign a unique character AT RANDOM to each player. There should be no player with the same character.

How I did it:
I used the Game Manager FSM of the Game 'GameObject' in demo_room, and did all the assigning there. I changed the instantiate player into that tries to assign the players one by one to a unique character. The variables I used here are booleans that flag which characters are taken (NETWORK SYNC IS CHECKED), and a Photon View and Game Object Proxy have been placed on Game (with the Game FSM hooked on the Photon View).

What happens:
It doesn't work. The players still get instantiated, and repeats happen. Sometimes, a character does not even get spawned (and it happens when I leave and re-enter the room).

I've tried putting delays but they didn't work, they still doubled themselves and won't appear properly at times.

I'm thinking of assigning the characters ONE BY ONE... but I don't know how to do it in Networking (it's my first time to do this thing)


Can anyone please help me? I'm stuck for 2 days now T__T. Thank you sooo much!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Photon - Assigning a player type one by one
« Reply #1 on: May 09, 2014, 02:39:44 AM »
Hi,

 Re your error, I am not sure, but it's likely a problem of logic, so study carefully how the demoworker is doing.

- Make use of room custom properies to keep track across your network of Player assignments. Also, you know how many players there is in a room, you can typically assign a predefine order for roles as you join, else simply record everything within the room custom properties.

- Typically, a network game also comes with a proper database, and so the likely alternative is to store the room reference and keep track within a database of what's going on, but for sure a lot more involving if you don't have experience with this.

Bye,

 Jean