Photon RPC() only calls remote objects?

Hi there,
I just want to confirm something with in the Photon RPC() call.

Firing this function will contact any photonview object ands it following script, and function inside. Yes?

The reason I ask is because my tests do far are only showing remote objects are called. Not local. Meaning, I fire myLocalPlayer.photonview.RPC(“doThis”, PhotonTaegets.All); & the result only seems to be passed to remote objects, not another local across the network. Am I dreaming???

My evidence is this, I have a two player multi player game. At player x wins, fire RPC(). The receiving function needs to ask if a manager is assigned, this is to prevent an error since a remote object will have no player manager (player controller). So I ask, if (mng) doThis().

The only objects returning are those with no mng. Do only remote.

Any ideas?

  • If you select all as target every photon view will execute the remote procedure call, scene views won’t be called until you send with scene view. Why would you call some thing that is extra marked with “Local”?. I don’t see any sense there.

Ok, maybe I am missing something.

My current situation is, player x wins scene objective. So, send message across network that the objective had been obtained by player x.

Right now, the player y on separate device is not notified.

What am I missing?

The error must be somewhere in your setup or code and it’s near impossible to list all options that might go wrong (beginning by “are both in the same room” to “did you load a scene on the second client, while in the room” and on and on).

Please work take a step back and work through the Marco Polo Tutorial, which explains using RPCs. If you do things that way, it will work and you can apply it to your case.

I will, but am I correct in assuming RPC calls all objects with a photon view across the network?

ps. The error is logical. If I instantiate player class at start (over photon network), I am creating (in my case), a local player class and his “reflection” on other devices.

The purpose of the reflection is only that, a reflection to the transform. He serves zero functionality. Therefore while he has a player script, he has no player manager (manager == null). On the other hand, the local player class does have a player manager, as it needs functionality (player input etc).

At win round, RPC is fired across the network. In player script I determined that if player manager is null, do nothing as this is a reflection object. If manager is not null, this is the local player, therefore, fire local procedures.

That’s it! But at the moment, if manager is not null (local player), is never reached.

Yes they are in the same room.

You’re doing it to complicated for your self:eyes:

But…, try that with RaiseEvent

Thanks,
I am having trouble with the logic tho…

  • I have a Multi Manager, which uses Photon, and is a Photon.MonoBehavior.
  • At “RoundWon()”, I want to fire the message across the network.
  • As such, my thinking was to call the Multi Manager at this point.

My attempts have two flaws…

   PhotonNetwork.RaiseEvent((byte)GameEventCode.TestEvent, "blankcontent?", true, RaiseEventOptions.Default);
 Debug.Log("RaiseEventcalled");
  • in my player script (MonoBehavior, not using Photon), “GameEventCode” is an error.
  • so, I decided to place this call into the Multi Manager, which does use Photon and is a Photon.MonoBehavior. However, the same error “GameEventCode”, is not recognized.

-Upon subscribing to an event in Awake or isMasterClient, I am confused as to the arguments I need to pass, and how to pass the arguments I need.

Please help Obi Wan!

As I understand you want to sync the “RoundWin()” with all players in room. Usually that’s rare event and should be a custom propierty hashtable.

How ever,

In your room inspector is an GameObject that has game manager script component attached and photonView added which will be automatically marked as scene view. Now I don’t know which type your game is but here’s an example:
There are 2 teams “TDM” each player killed will give a team point to the hitter team. So now let’s set the max points to 10.
Now in your room manager script with scene view you check for example:

private void CheckForRoundWin()
{
   if(PhotonNetwork.IsMasterClient) // only one client checks it,the master client
  {
     if(team.one.score >=10)
{
    SceneView.RPC("GameOver",PhotonTargets.All,(byte)TeamWinner.One);
}
else if(tea.two.score >=10)
{
SceneView.RPC("GameOver",PhotonTargets.All,(byte)TeamWinner.Two);
}
  }
}
[PunRPC]
private void GameOver(byte winner)
{
   switch(winner)
{
case 0:
// do something team one won
break;
case 1:
// do something team two won
break;
}
}

Thanks,
So I have to run, and I am getting an error I can slove, but am curious as to if my method is correct, so let me explain what I have done differently…

At roundWin(), instead of instructing the winning player’s PhotonView to RPC(“RoundWon”);, I have told player to tell the GameObject with Multi_GameLogic script, to use its PhotonView to RPC(“RoundWoN”);

The only major difference that I can see here is that by passing the RPC call to an object that exists in Awake(), that is not Instantiated across the Network, so has a PhotonView, but is only local.

Am I onto something?

Cheers and thank for the help.

That’s Scene View, it has nothing to do with players. Master will call game over and all other scene views will get that update. Here you can add your logic to make him leave and close room,set points to database what ever.

Simple in all: Master does check/call/change game state–> other will get the update and leave room or what ever you wanna add there.

Where is the problem? It’s hard to understand you…

As I say, I am away from the computer for the next couple of hours. Thank you for the help.

Will update.
Many thanks.

Sorry for asking, still away from computer, but the master, is this have subscribed events, or am I just firing custom functions with in it?

Is it “using photon;” and it must have a PhotonView? I am just wondering how a master’s various functions are properly triggered.

For instance, my player x clears level. Player script, tells master levelCleared()?

Only one client is master in room: the room creator or when he leaves another one will become master. Here we are using it to make sure only one player calls GameOver simple because we need it only one time. If there won’t be any master check, then every player in room will call gameOver and that’s… bad.

Ok, so this master, is the SceneView. It is a gameobject, named as such by default. It contains a PhotonView and my own Game State Manager?

Still, if that is all true, I still need an RPC() to fire and telling each player that the game is over!!!

Still away from 'puter. will be testing.

I give up .-.

Please read the whole PUN documentation: Pun 2 Introduction | Photon Engine

1 Like

Thanks for the help.
Almost there, I can feel it!

Ok,
I give up. Nothing seems to get this to work.

I have two players in room. Therefore, On each device I have a local and remote player.

When one player reaches the goal, it sends a message to the local GameLogic. This gameLogic, uses it’s PhotonView to RPC(“RoundWon”, PhotonTargets.All, winningPlayerID);

THATS IT!!!

WHY IS IT NOT WORKING!!!
AHAHAHHHHAHHHHHHHHHHHHHhhhhhhhhhhhhhh

Because it seems like your whole logic is wrong. It’s so damn simple to implement that but you already have problems there. I really suggest you to read first all how it works & general networking architecture. I guess you still didn’t read the whole documentation.