playMaker

Author Topic: Photon Playmaker Demo  (Read 11856 times)

markfrancombe

  • Sr. Member
  • ****
  • Posts: 338
Photon Playmaker Demo
« on: November 12, 2012, 05:35:44 PM »
After having kinda hi-jacked the New Actions thread for Photon, I thought I start anew here.

This is action more like a diary for ME, than anything, So EXCUE HUGE POST:

Please skip to second post for simple question.

Jean has offered to give me a hand when he has a moment, but for now Im trying to do a few things to the basic Photon Demo (https://hutonggames.fogbugz.com/default.asp?W927).

The changes I want to make are.

1. remove chat
2. remove all start-up interface (choose room, name player etc) to trick the player into thinking they are in a single player game.
3. Restrict to 4 players, (5th player to join should create a new room)
4. 4 separate spawn positions in the game, and...
5. 4 different models/ dialogues, animations, totally different stories infact.

Stage One: Removing Stuff from the demo.

The DemoWorker demo has 6 Game objects
1. The first is simply Unity stuff (light ground etc) + 1 FSM that simple turns on message queing
(I dont really know what this is except that I think its just turns the whole network s*** on... so I left it here..)

2. Chat. I just switched this off, It didn't stay off, but then you need to look at GameObject 3.
3. Enabler. This simple FSM, just seems to turn on or off the required items... including destroying the menu when you are done with it... As of Now I dont think it has ANY OTHER function than to check if you are in a room, and if you are, remove the menu, if not show the menu. As I will NOT be wanting a menu AT ALL I will probably have to come back to this but for now, I just turned off the Chat.. and tested...
Part 1 of my requirements ACHIEVED!

4. The 4th Game Object Game, has the FSM responsible for Spawning the player, its here I will no doubt come back to for counting the amount of players and spawning to different locations and using different Player Models, and has FSMs for checking if all is OK (whether we are in a room yet,) and displaying messages, and the Quit button. I can leave all this in for now, although the quit button currently takes you back to the menu (which I hope to remove) So I will have to come back to this, and see what to do here...

5. OK.. here it all is... the Menu or.. "the good stuff". Here I want to try to remove things, but still have them working...
It has 8 FSMs attatched. Connection, Connects and displays short messages.. I'll leave that
Connection failure button, to try again if connection fails... I'll leave that too... for now...
Create room Is important, as its a button to create the room... Ill need to Create the room, but, dont want people to know thats what they are doing.. So... on the Photon Network Create Room Action, I Add a hard-coded Room Name "Main" and change Max Number of Players to 4.
Ill turn off the Text field that allows you to choose a room (this doesnt work anymore anyhow) and change the name of the button from GO... to START. This will LOOK like a game start button, but actually its Creating a room, called "Main".
The remaining FSMs on the Menu game object are all about joining to rooms you have crated, listing the current rooms, and displaying Server information...
Join random room (dont want to do this)
Join room by title (dont want to do this)
Main Menu (seems to be just about NAMING your character, for the chat function... )
Room List Gui (displays the list of created room, I dont want this, Ive created one behind the scenes called "Main" .. and later will hope to create more rooms in the background, so that more than 4 players can play... MAin2 Main 3 etc... Ill get back to this)
Server Stats Gui (displays stats)

QUESTION... CAN I JUST TURN THEM ALL OFF?

I try... and... Its fails  >:(

The first instance works, I get a START button then a character spawns, BUT, its hard-coded to create a room called "Main" so when I launch a second instance of the game,  it fails..

Why.. because the only button I have left is the Create Room Button, that I have renames to START, so in other words, I am trying to create a "main" room twice. So I think I need to look back at my turned off FSM called Rooms list... turn off the gui stuff, but use the " do we have rooms" action, currently only resolving to YES, and listing the rooms,  If I can miss that out and go straight to Join Room (Photon network Join Room) I can add a NO option, where I add the Create Room thing from the Creat Room FSM.

Ill make BOTH buttons read START, so they will LOOK the same for all player, but actually the First Player, will be creating a room called "Main" and the second will be joining a room called "Main"..

Off to try now...


markfrancombe

  • Sr. Member
  • ****
  • Posts: 338
Re: Photon Playmaker Demo
« Reply #1 on: November 12, 2012, 05:48:46 PM »
Quote
Ill make BOTH buttons read START, so they will LOOK the same for all player, but actually the First Player, will be creating a room called "Main" and the second will be joining a room called "Main"..

YEah well it didnt work... But Im not sure why.. Heres my FSM, basically a modified version of the Room List FSM, but with an added NO target, so if there is no room created, I (hope to) display the Create Room button.


whoops.. bit big.. sorry...

What happens is that the first instance creates the room, the second one stops on CREATE ROOM, and if you press, it fails... (room already there)
BUT.. If I QUIT the first instance... THEN the second Instance CAN create a room, and then the First flips over to Join, and it all works lovely...
Is this to do with the Room Count thing.. whats that doing actually?
Where is rooms number variable being created? Is it built in Photon Variable?

The Quit thing gives me a hint, off to look at how that button works..


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Photon Playmaker Demo
« Reply #2 on: November 13, 2012, 04:59:56 AM »
Hi,

 It looks like you are getting a hang on all this. Are you aware of the documentation that goes with this demo?
 if you click on the blue book icon in Fsm editor view, you will be taken to the wiki, where each Fsm is documented and organized by roles ( criticals, or side features)-
https://hutonggames.fogbugz.com/default.asp?W927


bye,

 Jean

markfrancombe

  • Sr. Member
  • ****
  • Posts: 338
Re: Photon Playmaker Demo
« Reply #3 on: November 13, 2012, 05:17:51 AM »
Ha ha.. thanks Jean... yes Im getting somewhere... I am aware on of the blue book explanations (incredibly cool feature actually).

But this last thing did stump me last night. But it was getting late! :D

Im still a little unsure why this last thing didn't work. It should be a simple thing. Is the room created, ok then Join room, if not then create room.
Looking at the "Photon Network get rooms" action, (you need to scroll sideways to see it on my image) the Int Compare should be the action that sends the route to either YES or NO, Im not sure if thats where my problem is? OR... on create room, the charater still joins the room automatically and the player is Instantiated, in the GAME fsm. So Im wondering if I should move THOSE actions into this FSM, to after the join room action... Is the character being instantiated BEFORE the room is created?

Im a little confused about this.. as you can probably see...

But its been a good learning experience to go through the whole demo, figuring it all out for myself...

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Photon Playmaker Demo
« Reply #4 on: November 13, 2012, 05:45:58 AM »
Hi,

 Yes, the best way to learn is to study this example indeed. Sure if I had time to create tutorials and screencast that could help, but actually, getting your hands dirty in this is the ultimate way, so keep up.

 Ok the key process with this demo is that instanciation only happens when the scene is reloaded. Do you understand that? maybe you are not reloading the scene properly under your new logic?

bye,

 Jean

markfrancombe

  • Sr. Member
  • ****
  • Posts: 338
Re: Photon Playmaker Demo
« Reply #5 on: November 13, 2012, 03:13:16 PM »

 Ok the key process with this demo is that instanciation only happens when the scene is reloaded. Do you understand that?

HA! I do now!!

maybe you are not reloading the scene properly under your new logic?

GOT IT!! GOT IT!! So thats why it worked when one of the clients quit and came back in!!!
I WAS wondering why that reload thing was there!!! Still dont get it frankely, but OK.. I see wht to do... the reload was prob in one of the FSMs Ive disabled...

Off to the wood shed!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Photon Playmaker Demo
« Reply #6 on: November 14, 2012, 01:33:20 AM »
Hi,

 yes, the key aspect of this demo is that the scene is the same for all the different state of the network status and player. Elements are disabled ans enables when the game Start depending on this network state.

 that's why we have the Enabler GameObject.
 

You can go a different way with this and have a scene per status, for example a scene when the player has to select a room, and a scene when the player enters a room. you can get a modified version of the same demo using this technic here:
http://hutonggames.com/playmakerforum/index.php?topic=2342.msg10516#msg10516

bye,
 
Jean

markfrancombe

  • Sr. Member
  • ****
  • Posts: 338
Re: Photon Playmaker Demo
« Reply #7 on: November 14, 2012, 10:01:59 AM »
Yes this is very interesting Jean...
I will d/l the new project and take a look.

Can you think of any reasons why one method is better than another?

Personally I like that everything is in one scene, but I am wondering how to handle some future elements in my game. My game starts mostly in an exterior landscape, but pretty quickly each character will go inside.
For simplicity and file size, I was expecting to put the interiors in separate scenes... and maybe they will act as single player areas, each character experiencing the interiors alone... but when they leave the building, they are back in a multi player scene, I'm assuming that this is repetitively trivial? I ll have to also get into saving and synching more than just character positions.

When the doctor arrives in the game, they arrive by bus. This has a cut scene, but Ill want that bus to be visible from all the other players that might be watching.

When the Laboratory assistant wakes from being knocked out, they are in a trashed research centre...(already in a single player game) and his colleagues are leaving in a helicopter, this helicopter should be visible by the 3 other players in the game.

So Ill need to send synching info to the other players at set points... Im hoping this is just by attaching a photon view and some small code... rather than a huge deal...

It may be absolutely easiest it all these interiors are also actually in the main scene, just hidden. and players never leave.

markfrancombe

  • Sr. Member
  • ****
  • Posts: 338
Re: Photon Playmaker Demo
« Reply #8 on: December 01, 2012, 06:29:19 PM »
After a week of modeling and environment stuff, Ive come back to this issue:
Havent got much further. I think Im pretty stumped.. I may have to post the whole project and ask if someone clever can take a look.

But Ill ask describe 1 thing and see if thats a clue to ist not functioning.

Currently, IF I launch 4 instances of my project I can see the CREATE ROOM button on a four screens. I click Create on ONE and all the other 3 instances change their button to the JOIN ROOM button (remember, when it works Ill make thses 2 buttons lokk exactly the same so used wont be aware if they are Creating or Joining.)

SO FAR SO GOOD... (Currently it fails if I create a 5th player, as I have MAX layer set to 4 - in the end I want a new room created.

BUT... If the instances are NOT launched. IE waiting with all thier respecting CREATE ROOM buttons, but instead I launch and run one instance, click Create Room, THEN launch another instance, THEN its says CREAT ROOM TOO, when it should launch, realise a room is created alread and the butotn should display JOIN instead...

So its something to do with NOT checking if there is a room, ON LAUNCH...

Hmmm

markfrancombe

  • Sr. Member
  • ****
  • Posts: 338
Re: Photon Playmaker Demo
« Reply #9 on: December 07, 2012, 06:14:36 PM »
Another week, and even less time to work on this. Every time a get a spare hour, (kids, life goddamit!)  I start from scratch again!

Im going to be really cheeky and post my whole project as a zip, if you get the chance maybe you can take a look?

https://www.dropbox.com/s/9q20zxeyxjgqd3n/MARK%20F%20Unity%20PlayMaker%20Photon.zip

Within the project there is the UNALTERED original project file(PlayMakerDemoWorker), and my one that isnt working (MARK_PlayMakerDemoWorker)

WHAT IS WORKING:
I have removed all functionality I dont want (chat, random room, create named room etc) and have a new combination FSM (Create and Join) that either creates a room (entitled MAIN) or, if a room is created, displays a button called JOIN room (It joins a room called MAIN).

WHAT IS NOT WORKING:
If only one instance of the game is launched and a room is created, subsequent instances launched, will display CREATE ROOM button, NOT the JOIN room button. (It should jump straight to JOIN, not CREATE)
If up to 4 instances are launched and running, THEN IT WORKS; (All 4 display CREATE until one is clicked, then the other 3 change to JOIN, and when they are Joined, it works. BUT all instances MUST be running before the room is CREATED.

I think this is the heart of my problem, if this was corrected and I understood how, I think I would get the rest.

WHAT STILL NEEDS IMPLEMENTING:

1) Currently Im only making 1 room (MAIN) I need this to make another room, IF that room is full (MAIN2 perhaps) just on the off chance that more than 4 people ever play at once (remember my game is ONLY for 4 people, its a story, with 4 characters.)
2) The 4 characters need to be 4 separate models (Preferably in a random order each time, so "The Priest" is not always the first to be created.
3) They need to Spawn to 4 separate locations, dependant on which character they are. ("Priest is always at the church).

But if I can just get the first problem working, that would be a start.

If you don't have time to look at my project, a hint would be good...

Regards
MArk


PS:What is your hourly rate for paid work? Im getting close to wanting to pay for this!!! Although I do feel that I need to understand this, the game aint finished just cos this works... loads to do yet!!!






 

markfrancombe

  • Sr. Member
  • ****
  • Posts: 338
Re: Photon Playmaker Demo
« Reply #10 on: December 10, 2012, 04:14:29 PM »
Bumping?

Still no joy, but heres a hint, might mean somthing to someone:
1.  i launch a build,
2. I launch another
3. Hit Create on one
4. The other instance changes to JOIN (all goo so far)
5. THEN I start up the Unity Program Version
6. It gets the CREATE button (It should be JOIN now)
The console shows THIS:
createGame failed, client stays on masterserver: OperationResponse 227: ReturnCode: 32766 (A game with the specified id already exist.). Parameters: {}.
UnityEngine.Debug:LogError(Object)

So.. what does that mean I need to do?

:-)

M

markfrancombe

  • Sr. Member
  • ****
  • Posts: 338
Re: Photon Playmaker Demo
« Reply #11 on: December 10, 2012, 06:19:39 PM »
YIPIIII, SOLVED.. a bit...
 ;D
First THING solved at least:

In making my new FSM that combines both the Create and the Join FSMs from the original demo, I missed one thing.

I always thought that the text "no existing games" was on the Room List Gui FSM, which displays the list of rooms as they are created. But when I looked for that text, (my clue being that if THIS text successfully changed on load, then the solution must lie nearby) I discovered that actually this text is in the Random Room FSM.

When I looked at it, the start Transition of the Random FSM has PHOTON/RECEIVED ROOM LIST, but I only had PHOTON/RECIEVED ROOM LIST UPDATE, because that is what came with the list rooms gui action in the demo.

I went back to my new FSM and added this Global Event,
So now my start thingy has
PHOTON/RECEIVED ROOM LIST UPDATE
PHOTON/STATE: CONNECTED
PHOTON/RECEIVED ROOM LIST

I hope this doesn't cause a problem, and now Im gonna have to test like hell before getting to work on the next problem...

Watch this space...

Mark!
 :-*

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Photon Playmaker Demo
« Reply #12 on: December 11, 2012, 04:49:42 AM »
Hi,

 I am glad you are able to make some progress on all this! The room creation dance is indeed something to really grasp, and the demo provided do not cover this is a secure manner so you will need to check if a room exists, and then change the UI to adapt fo each cases, and that is so dependent on your game that I don't think a generic solution would be feasible, that's what it's left up to the developer to do that ( some game will create rooms automatically, some will allow the user to do this)

bye,

 Jean

markfrancombe

  • Sr. Member
  • ****
  • Posts: 338
Re: Photon Playmaker Demo
« Reply #13 on: December 11, 2012, 10:54:54 AM »
Thanks Jean..

I tell you I was SOooo stuck, for 3 weeks , anytime I had I stared at this. You just have to be like a detective and check and compare every small thing with the working demo.

I understand what you say that its difficult to make this as a template for all, and in the end you DO need to understand it completely to change it into what you need, however this solution, was very obscure.

The RECEIVED ROOM LIST and the RECEIVED ROOM LIST UPDATE, are so similar, Im not sure why we need both. Surly if we get the room list at a time when we need an update on rooms, we get the result we need?

Anyway, tonight I start on giving the room a name+number that increments after each 4 players, creating rooms as needed. (tricky to test!!)

Then its on to spawning 4 different models to 4 different locations. (YIKES!)

You muttered something once about ArrayMaker sometime on this subject, can you point to a thread or docs on this, need to check if I should go that way.

cheers

Mark

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Photon Playmaker Demo
« Reply #14 on: December 11, 2012, 04:48:59 PM »
Hi,

 I think the two ROOM events are different in how fast they get updated. I have ported the Photon api exhaustively, so I had to have both, I know one of them is only updated every 5 secs or something. So it might simply be there to provide alternative for less bandwidth. Plug both I would say.

Good luck with your dev :)

bye,

 Jean