playMaker

Author Topic: Please Help with som photon logic  (Read 1461 times)

Ofonna

  • Full Member
  • ***
  • Posts: 230
Please Help with som photon logic
« on: June 28, 2017, 10:28:42 PM »
hi guys, so i finally figured out a problem to my photon issue, i needed each player to individually have their own bullet, e.g player1 to shoot player1 bullet and player2 to shoot player2 bullet.

this is great, but setting the tags for my players is the issue, as each client handles their management differently.

my initial method,
get number of players in room (maximum players = 2), this is an int variable

[int compare]
if [number of players in room] is equal to one,
set tag to player1,

else if [number of players in room] is greater than one,
set tag to player2,

This works great on the master client because we have to wait for player2 to join, but player2 immediatey sets all instances of players to player2 tag which causes it not to work properly.

is there a way i can get the other player instance, so i can easily set the tag.

thanks!!!

ps photon is awsome! :)
thanks to jean for the advise

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Please Help with som photon logic
« Reply #1 on: June 29, 2017, 02:22:54 AM »
Hi,

 ok, for this, you can use PlayerRoomIndexing component available within Photon Unity Networking, it will automatically number players. Just add that component in your scene ( check the inspector, it will work at runtime showing indexing live) so double check first that this is what you want.

I created an action so that you can get it, it's not yet in the package, but you can get it here:

https://github.com/jeanfabre/PlayMaker--ExitGames--PhotonUnityNetworking_U4.3.4-Library-/blob/645c64bc1675fa8640fd24718a8301a28aa3412b/Actions/PhotonNetworkGetPhotonPlayerRoomIndex.cs

Always wait one frame before making this request when player joins, time for the component to do it's job of saving indexing in room custom properties.

 Bye,

 Jean
 

Ofonna

  • Full Member
  • ***
  • Posts: 230
Re: Please Help with som photon logic [solved]
« Reply #2 on: June 29, 2017, 03:08:07 AM »
hi, thanks Jean, i was able to come up with a patched up solution but this is the exact action i need, but i keep getting the null reference expection

(NullReferenceException: Object reference not set to an instance of an object)
i think the "use owner" isn't working in the script

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Please Help with som photon logic
« Reply #3 on: June 30, 2017, 04:32:04 AM »
Hi,
 
d'oh, action is corrected and tested this time :)

Bye,

 Jean