playMaker

Author Topic: Photon RPC Event driving me insane  (Read 7912 times)

will_brett

  • Junior Playmaker
  • **
  • Posts: 72
Photon RPC Event driving me insane
« on: February 16, 2013, 01:07:34 PM »
This is driving me nuts now.  >:( ??? :'(

I've started a new thread as it is slightly different to the old one and things will just get confusing in there.

1: Ok, so what I have done is make an NGUI button which sends a "Photon View RPC Broadcast FSM Event" (See image 1) I have checked the exclude self so that this will only be broadcast to other players.

2: Next I have an empty game object which I have named SpawnPoint. This FSM receives the Event from part one and uses a "Photon View Get is Mine" action (Image 2). I then use the "is Not Mine Event' to go to next state which is a "Create Object" action (Image 3). This create a 2D sprite on the SpawnPoint mentioned above (Empty game object).

Now when I come to test it I set the Mac computer to host and the ipad joins that room. I click the NGUI button which sends the event to whoever is NOT the host, no matter who pressed the button.

Example 1:

Host presses button - game object appears on other players screen

Other player presses button - game object appears on the player that pressed the buttons screen.

I really don't know where I'm going wrong with this. Its very frustrating.


Looking forward to hearing your responses... all the best

WB

Note: this is a two player game




jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Photon RPC Event driving me insane
« Reply #1 on: February 18, 2013, 12:45:45 AM »
Hi,

 ok, let's do this different. Can you explain what behavior you want between the two player. Let's say player A and player B. Here, It's not very clear ( maybe cause I am not a native english speaker) what is the expected behavior and what you experience in reality.

 So you want:

Player A press a button and send an event to Player B  ( and player A DO NO RECEIVE THAT EVENT)

is that correct?

Hosts have NOTHING to do with sending events from player to player. How do you know and/or check who is the host? I think you may be confused by the concept of host and owners.

You don't have an image attached to this post, can you add it? I just want to check what action you are using to send that rpc event. Like on your other thread, I think it's simply because you don't use the right action, you should use the one that targets players and not the global one, tho that should work too if you choose "OTHERS" as targets.

 so you should use this action:  Photon View Rpc Broadcast Fsm Event To Player
https://hutonggames.fogbugz.com/default.asp?W921

And LEAVE the Event target to BroadCastAll. This is important.

And fill of course the Target Player Name with the right value ( if you have trouble with this look at the photon demo as well, I do use action on the chat)

Bye,

 Jean



will_brett

  • Junior Playmaker
  • **
  • Posts: 72
Re: Photon RPC Event driving me insane
« Reply #2 on: February 18, 2013, 06:27:09 AM »
Hi Jean,

Thanks for helping me out agian.

Yes that is correct: Player A press a button and send event to player B (And Player A does not receive event)

I will attach an image later when I am working on it again.

I had a look at the Photon demo and if I follow the "Send To Others" states(Image1) it has a "set string value"(Image 2) but there is nothing named "others under variables" (Image 3)

then there is a "get string Fsm" plus "Photon view RPC Broadcast FSM Event" (Image 4)

so Im confused as to what is going on and how it works.

Thanks
W

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Photon RPC Event driving me insane
« Reply #3 on: February 18, 2013, 11:58:00 AM »
Hi,

 indeed ,  "Photon View RPC Broadcast" property "photon target" has the option "OTHERS".

 in the demo, I use a variable to store the photon target, that's where you might loose the process. When you play the scene, pay attentions to the variables value, and also simply pause and use debug flow to step backward and study in your own time the processes. it's easier than when playing, especially here when it bounces between different fsm.

 You are not far.

In your case tho, Have you considered using "Photon View RPC Broadcast". Study also my demo and the chat related to sending a chat to a particular player, since you only have two, it should be easy.


bye,

 Jean

will_brett

  • Junior Playmaker
  • **
  • Posts: 72
Re: Photon RPC Event driving me insane
« Reply #4 on: February 18, 2013, 08:44:26 PM »
Thanks for the reply :) much appreciated.

I am trying to use the "Broadcast FSM event to Player" action as you recommended. I've gone through your demo and Im sure Im getting close now.

However I am still struggling. When I click NGUI button I now have a GUILayout appear with the "Photon GUILayout Toolbarwith PLayers" action. (Image 1)

I would rather this just be integrated into the NGUI button so I only have to press it once but can not figure out how.

Once I have clicked the "Photon GUILayout Toolbarwith PLayers" button it goes into a Broadcast event to player photon action (image 2)... it's at this point where I get an error message. (Image 3)

The photon broadcast to player FSM should be sending a remote event named "CREATE" to a new FSM. This new FSM uses a "Create Object". This object should be appearing on the other players screen.

Sorry to keep pestering.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Photon RPC Event driving me insane
« Reply #5 on: February 19, 2013, 12:24:38 AM »
Hi,

Do not worry, i am here to help and guide you if i can.

In your case you can ignore that player toolbar since anyway you only have two players isn't it?

So have a single button like you want, this is fine. Look at the fsm "chat target gui" and state "set to other" that's the quickest way for you.

Bye,

Jean

will_brett

  • Junior Playmaker
  • **
  • Posts: 72
Re: Photon RPC Event driving me insane
« Reply #6 on: February 19, 2013, 07:07:21 AM »
Thanks again for replying.

I had a look at the "Chat target GUI" again and tried to follow it as closely as I could.

But now it doesn't seem to send to anyone. I've attached the images of my FSM.

(If I swap out the "Photon broadcast to player" to "Photon broadcast event" it sends the event to both players.)

 

will_brett

  • Junior Playmaker
  • **
  • Posts: 72
Re: Photon RPC Event driving me insane
« Reply #7 on: February 19, 2013, 11:59:34 AM »
Im just wondering what the point of "Set string Value" is. In my case the string is set to others... and that is being sent through the photon broadcast event... but what does this string do? Is it something that photon recognises or is this something that I need to implement myself for it to know to only send to others. As in my case is seems to be doing nothing.

I've gone through all the photon documentation and looked at the demo scene countless times and still can't figure it out. :(

will_brett

  • Junior Playmaker
  • **
  • Posts: 72
Re: Photon RPC Event driving me insane
« Reply #8 on: February 20, 2013, 04:23:10 PM »
I feel like I have tried everything now, including just copying the FSM from the demo project and still not working. My chat room is working fine with the send to all option.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Photon RPC Event driving me insane
« Reply #9 on: February 21, 2013, 12:22:40 AM »
Hi,

"others" is indeed a keyword that photon understands. If you look at the action help online ( by clicking on the blue help book icon, you'll get that link:

https://hutonggames.fogbugz.com/default.asp?W920

 The property "photon target" is the one you can set manually when you know for sure on that state what target you want.

NOW, for flexibility ( and because playmaker can not store enum values in Fsm variables yet), the second field, is the string representation of the photon target, meaning you can save it in a fsm string to have a more flexible state ( like on the demo).

IF you set the string of the property "Photon Targets From String" it OVERRIDES the photon target.

In your case, leave "Photon Targets From String" to "none" and simply select "Others" in the photon target.

 Does that make sense?

bye,

 Jean

will_brett

  • Junior Playmaker
  • **
  • Posts: 72
Re: Photon RPC Event driving me insane
« Reply #10 on: February 21, 2013, 09:16:31 AM »
Oh WOW it is now working! Thank you so much. I swear I already tried this step but I kept getting an error.

Thank you for all your patience I really appreciate it

All the best from the UK

WB

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Photon RPC Event driving me insane
« Reply #11 on: February 21, 2013, 10:04:53 AM »
Hi,

 Excellent! perseverance is key, I am glad you kept at it :)

 Have a good day from Russia :)

Jean