playMaker

Author Topic: PHOTON help - Identifying a player's instance  (Read 3820 times)

charming_fox

  • Junior Playmaker
  • **
  • Posts: 54
    • View Profile
PHOTON help - Identifying a player's instance
« on: July 13, 2015, 02:49:03 AM »
Hi,

So, really thinking hard about this one, but it must be possible, just not sure how to get the data, here's the scenario:

I would like the chat box to only be populated by chat messages coming from nearby players, I've recreated and modified the demo-worker chat functionality to work with uGUI and it works great.

What I think would work is (bold I'm stuck with):

RPC call comes in with the chat string
"Get Last Message Player Properties" identifies the sender-player's name
Identify the avatar that the sender-player inhabits
Test the distance, if it's within x units then continue to build the string
else, do nothing.

So, any ideas on how I can identify the players instance to check their distance?

Many thanks!

A

« Last Edit: July 13, 2015, 08:39:41 AM by charming_fox »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14684
  • Official Playmaker Support
    • View Profile
Re: PHOTON help - Identifying a player's instance
« Reply #1 on: July 13, 2015, 03:28:03 AM »
Hi,

 The most reliable way is to use the networkId assigned to each Player, Player A with have the same network Id across the game on all running instance.

Use the action "PhotonViewGetID" on the GameObject of the players to know about it.

 have you tried that?

Bye,

 Jean

 

charming_fox

  • Junior Playmaker
  • **
  • Posts: 54
    • View Profile
Re: PHOTON help - Identifying a player's instance
« Reply #2 on: July 13, 2015, 06:15:29 AM »
Thanks, I haven't but have considered it, before I go diving in and messing around would it require each player sharing their own instanciated avatar(gameobject) photon ID through the avatar's variable sync repo?

Thank you!

charming_fox

  • Junior Playmaker
  • **
  • Posts: 54
    • View Profile
Re: PHOTON help - Identifying a player's instance
« Reply #3 on: July 13, 2015, 07:53:09 AM »
ok I think I've found it:

I'll use 'set player custom properties' on the instanciated player game objects as they come in...

Photon Get Last Player Properties can be expanded to get custom properties, so now I'll be recieving the string for the chat along with the custom property 'sender's avatar' which is the game object... simples!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14684
  • Official Playmaker Support
    • View Profile
Re: [SOLVED] PHOTON help - Identifying a player's instance
« Reply #4 on: July 13, 2015, 08:07:48 AM »
Hi,

The player custom properties is indeed a way, but the networkID would be just as good, and no you don't need to synch the networkId, since it's the base for synching, that would turn the system on its head :) you can synch variables values because indeed the network system manage objects to synch using their network Id.

Bye,

 Jean

charming_fox

  • Junior Playmaker
  • **
  • Posts: 54
    • View Profile
Re: [SOLVED] PHOTON help - Identifying a player's instance
« Reply #5 on: July 13, 2015, 08:37:03 AM »
Hi Jean,

You're right, i've got myself in a mess... what I don't understand is, yes I can get the player's ID easily enough, but that doesn't have any XYZ world coordinates as the chat system works from uGUI's Canvas...

i.e. I still don't understand how I should efficiently identify the sender's game object that they control based on Get Event Info

...
think I might leave it for today and come back with a fresh mind tomorrow.

Thanks!
« Last Edit: July 13, 2015, 08:39:33 AM by charming_fox »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14684
  • Official Playmaker Support
    • View Profile
Re: PHOTON help - Identifying a player's instance
« Reply #6 on: July 13, 2015, 09:32:10 AM »
Hi,

 Your players have avatars in 3d walking in some scene right? this is where you'll get them positions.

 What chat system are you using? my version on the wiki is not using ugui.

Bye,

 Jean

SeriousRPG

  • Playmaker Newbie
  • *
  • Posts: 45
    • View Profile
Re: PHOTON help - Identifying a player's instance
« Reply #7 on: July 25, 2015, 03:02:48 PM »
Hi,
I am also in need of the demo worker's chat functionality in the new UGUI. Is there a demo or file updates I can get to do that? I am not sure how to remove the GUILayout and replace it.

Thanks,
Sandi

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14684
  • Official Playmaker Support
    • View Profile
Re: PHOTON help - Identifying a player's instance
« Reply #8 on: August 27, 2015, 05:51:52 AM »
Hi,

 yep, I'll be starting on porting the photon demo to uGui soon.

 Bye,

 Jean

rongconcrx

  • Full Member
  • ***
  • Posts: 132
    • View Profile
Re: PHOTON help - Identifying a player's instance
« Reply #9 on: December 05, 2015, 08:51:48 PM »
Hi, any chance you got it working with the new ugui? Thanks

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14684
  • Official Playmaker Support
    • View Profile
Re: PHOTON help - Identifying a player's instance
« Reply #10 on: December 09, 2015, 12:14:01 PM »
Hi,

 I hope to get to this very soon, but not before january I am afraid.

 Bye,

 Jean