playMaker

Author Topic: Photon Players HUD Same As Owner  (Read 5537 times)

Fletch

  • Junior Playmaker
  • **
  • Posts: 66
    • SneakOnTheLot.com
Photon Players HUD Same As Owner
« on: June 22, 2013, 01:14:58 PM »
I know I'm doing something wrong here.  If I had a little guidance I think I could figure it out.

Here's what's happening.

I've started a networked game with Photon and it's working great... for the most part. 

Once I had people running around I decided to start adding in some things like, prefab pickups for money.  Sounds simple, right?  Well, it would be if it were a single player game.  Unfortunately for me, I haven't quite figured out the nuances of network games and the photon server because what I have is a HUD that displays the current amount of gold.  When someone picks it up, it increases their gold by 1.  The bad part is that everyone else's gold just increased by 1 as well.  What ever 1 player does, the others all see.

The same is true of an inventory button that just pops a gui box.  When one person presses theirs, all the other players see it.

How do you target the player and update only their information?

Fletch

  • Junior Playmaker
  • **
  • Posts: 66
    • SneakOnTheLot.com
Re: Photon Players HUD Same As Owner
« Reply #1 on: June 22, 2013, 06:15:48 PM »
I'm almost certain that I should be using the RPC calls to a specific player but I am just looking for a warm blanky cause I'm scared to go out trying to do something that just isn't the way it should be tackled.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Photon Players HUD Same As Owner
« Reply #2 on: June 24, 2013, 04:19:35 AM »
Hi,

 RPC is one way to get there. Study the chat system of the sample provided ( on playmaker sample page), and you'll see how to use RPC to target a specific user.

 BUT, now there is a much better way I feel, using player custom properties. The last iteration of playmaker support for Photon now includes access to room and player properties.

 So, simply add/set/get/ your player property "score", and get notified with the global event "PHOTON / PLAYER PROPERTIES CHANGED"


bye,

 Jean

Fletch

  • Junior Playmaker
  • **
  • Posts: 66
    • SneakOnTheLot.com
Re: Photon Players HUD Same As Owner
« Reply #3 on: July 09, 2013, 04:13:26 PM »
This worked perfectly!  Thank you!

Fletch

  • Junior Playmaker
  • **
  • Posts: 66
    • SneakOnTheLot.com
Re: Photon Players HUD Same As Owner
« Reply #4 on: July 10, 2013, 05:05:51 PM »
Did you mean to write Add in that list of "add/set/get your player property?".  Cause there is no Add Property action.

There is a - Photon View Get Owner Properties
and a - Photon Network Set Player Custom Property

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Photon Players HUD Same As Owner
« Reply #5 on: July 11, 2013, 07:06:47 AM »
Hi,

 Set is "Add" as well if that property is not found. Sorry, I should have been clearer.

bye,

 Jean

Fletch

  • Junior Playmaker
  • **
  • Posts: 66
    • SneakOnTheLot.com
Re: Photon Players HUD Same As Owner
« Reply #6 on: July 12, 2013, 08:20:08 PM »
I have no idea what I'm doing and my head is about to explode.  I've read all the documentation over at Photon so at least I'm more clear on the vocabulary.

Let me see if I can encapsulate the basic concept of running a multi-player game and someone PLEASE tell me I'm right or give me something more to go on.

I've dissected the demo and have come to the conclusion that there needs to be a Game Manager (not unlike what is in the demo) who's role it is to act as the Dungeon Master for all the Players (Actors). 

This Dungeon Master simply listens to anything that happens and who does it, then awards points, damage, gold, items... whatever, to the player who did the action.

Am I at least close?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Photon Players HUD Same As Owner
« Reply #7 on: July 15, 2013, 01:56:27 AM »
Hi,

 Any games needs some kind of manager after some point of complexity and features.

awarding points doesn't need a global manager, your player or feature logic can do that by itself. It can talk to a manager and say "Add x points to player", but not necessarly "Player did this" and then let the manager decide how many points to attributes.

It's really here a question of personal taste really. Some prefer using managers and take away as much responsability from the features, and some prefer giving more freedom to each features and give them responsibility.

I know it may sounds like not really answering :) Photon has nothing to do with these kind of decisions actually.

So, I would recommand not to use a global manager if you are starting with all this. You can always move the logic into a manager later, while I found that doing the opposite is a lot more complicated to refactor.

So, actually, empower your player and features to handle themselves on their own, and only let global managers deals with things like where to get info and how to load save data.

so, your global managers knows about databases, player prefs, etc etc, while your features only know about their "points" and "awards", not carring about how and where it's actually stored.

does that make sense? if you go this way, you can easily build new features, adapt your game for a different platform that has different ways of storing retrieving data, etc etc

I think that your thinking process is getting confused because of the concept of "server" on multi player games right? here with photon, there is no server, therre is no central brain where you can manage a game. SO, if you create such dungeon Master, it will need to be a special kind of player, one that doesn't count as a player in the lists, and is invisible in the 3d, yet, present in all running instances. And then it can receive and dispatch orders and details to all players or particular players when necessary.

Make use of room custom properties. It's a new feature I ported. You can add custom properties to players and rooms. Your "room" can then host details about that particular game, and players / and your dungeon master can rely on this to know the states of the game.

does that help a bit?

bye,

 Jean

Fletch

  • Junior Playmaker
  • **
  • Posts: 66
    • SneakOnTheLot.com
Re: Photon Players HUD Same As Owner
« Reply #8 on: July 15, 2013, 10:55:27 AM »
Fantastic!  This helps a lot!

So now I'm zeroing in on what it needs to be.  Now I have a specific question that your answer brings up.

Here is my situation:

I Have gold coin that players run into to pickup.  It all works great except it's not giving points to the right player.

The rig looks something like this...

GOLD COIN PREFAB
State 1 ) The coin has a trigger on it.
State 2) I needed to find out what player just ran into it so I also store the name of the player in a variable here.  Then I use that variable to call a Photon View Get Owner Properties.

Herein lay the problem because the owner of the player object is always, Player:ME, Regardless of who runs into it.  So when I now update my player, it's effectively updating all of the players.  How do I get the name of a player, not the object the player controls.




Fletch

  • Junior Playmaker
  • **
  • Posts: 66
    • SneakOnTheLot.com
Re: Photon Players HUD Same As Owner
« Reply #9 on: July 15, 2013, 06:54:16 PM »
Okay, I think we've solved this one.  It's not you guys to be sure.  It's my brain and forcing it to think differently in a multi-player environment.

So here is the setup I ended up with.  Future readers can follow it or ignore it... or perhaps I can get a confirmation that I'm on the right path.

FIRST
The gold coin needed a lot more work than I would have thought.  This little prefab is doing a good bit of work.  First off, it waits for a trigger.  When you set it off, It gets your player properties and also saves a bool var that it then test to make sure its local.  If it's not then it resets the whole thing.  If the player IS local then it adds a random number between 1-10 to the gold count.

When the player's custom gold property is increased, it alerts the HUD.

The HUD then gets the new custom property number and changes the INT to a String, which it then places in a GUI Box.

One little trick was to also test the GUI Box at the beginning of the game and make sure to only display the local player's GUI.  I was having issues with this thing displaying every single GUI gold Box from every player.

That sound about right?


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Photon Players HUD Same As Owner
« Reply #10 on: July 28, 2013, 11:44:34 AM »
Hi,

 That's sounds all very good to me. If you want me to run a double check on your implementation, don't hesitate to share it to me, I'll have a quick look.

bye,

 Jean