playMaker

Author Topic: Photon RPC event to specific instantiated object?  (Read 9086 times)

Swift_Illusion

  • Playmaker Newbie
  • *
  • Posts: 41
    • Midnight Tinkering
Photon RPC event to specific instantiated object?
« on: October 13, 2013, 08:29:05 PM »
I'm trying to setup actions for players, that are a player object instantiated with every client that joins, but when trying to send an RPC event to the character it sends it to every single instantiation of that object.
So I can't target player 1 or 2 individually for things like death/restarting/etc in any easy manner. I've even tried renaming the object but it still picks up that they are both instantiations of the same prefab and sends the RPC to all players.

I'd really appreciate knowing if there's a way to target specific instantiations of an object throughout the network because it's really hard at the moment to try and get any change to happen easily for a player, especially when there's any lag.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Photon RPC event to specific instantiated object?
« Reply #1 on: October 14, 2013, 08:04:32 AM »
Hi,
 
Can you study the chat system implemented in the Photon demo? you can target individual players.

Have you looked at the demo at all actually? it's important you start with this demo to get acquainted with Photon if you never worked before with it.

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


bye,

 Jean

Swift_Illusion

  • Playmaker Newbie
  • *
  • Posts: 41
    • Midnight Tinkering
Re: Photon RPC event to specific instantiated object?
« Reply #2 on: October 14, 2013, 10:12:15 AM »
Yeah I know you can target individual players, as in their client,
but that isn't my problem.
The issue here is being able to target a specifically instantiated object
across every client. I know you can relay some information by through synching,
like how the movement/rotation is synched across each client, however that information is owned by a single client.
I want send an even that event that will act in every client because I have
a different action based on whether it's in the client that owns it, or the other clients that don't own it.
However if I have 2 of these objects instantiated, it will activate that event on both objects.

What I'm trying to achieve is an event to be sent when a player collides with an object, however I can't send it individually by targeting the object hit and sending a GameobjectFSM event because if the player moves away from the object too soon, with the synching across the network it might not actually collide on some clients.

Also for situations where I'd need to trigger the death of a player, I can't target the individual player object across all clients through any means, or at least none I've found.
Currently I have to freeze my player and instantiate an object across the network which when colliding with the player object, it destroys it.
Because everything else I tried, the latency causes issues between clients.

I already studied the demo's before starting the project but they don't help with this situation.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Photon RPC event to specific instantiated object?
« Reply #3 on: October 15, 2013, 02:19:25 AM »
Hi,

 the chat system exposes the various options to fire an event across the network, you can send to a particular user or to ALL, so simply send that event to ALL. it's one or the other here, there is not in between as far as I know.

I think we have a problem of vocabulary, what do you mean by "target a specifically instantiated object", either you want to target a given instance across the network ( sharing the same photonview id) or everyone.

could you explain how the chat system should be modified to fit your need? cause essentially, the chat system is the best way to describe communication between instances and players. So could you give me a use case? like USER A sends a chat to self or USER A sends a message to ALL USERS etc etc. If we can implement your use case within the context of a chat, then you'll be able to apply it to anything else, and instead of sending a chat message you'll send what's relevant.

 Now, if you are looking for streaming, streaming can only happen within the same photonview id, there is not other way. for any other mean, you'll have to code it yourself, like passing on the streamed values to other players within the same instances ( using regular events, as you do without photon being involved).

bye,

 Jean

Swift_Illusion

  • Playmaker Newbie
  • *
  • Posts: 41
    • Midnight Tinkering
Re: Photon RPC event to specific instantiated object?
« Reply #4 on: October 15, 2013, 12:33:48 PM »
To try and explain it better,
as an example and not my current usage for it-
I have a player prefab, and in each client that player prefab
will be instantiated, when a player joins the game.
So 5 players have joined the game, 5 instantiations of that prefab,
and now I want one of them to when colliding with an object,
have an event occur.
I can't be sure that the player will actually collide with that
object in every client because of the way it's synched-you might
move away and the synching skip the frame you would have
collided with that object in another client and so the event
wouldn't trigger, causing a problem.
So I want the scene that is the owner of that object to send
an event to that specific players 'object' across all clients with a
"Photon View RPC Broadcast FSM event" action.
The issue is this will send that event on every player because they
are all instantiated from the same prefab.

No matter what I've tried, I can't get it to just send it and only affect
the player object I sent the "Photon View RPC Broadcast FSM event" action with.

Note:
I have set it up correctly, using "Game Object" for the 'Event Target',
and "Use Owner" for the 'GameObject'.
Also my reason for needing it won't be solved by sending a normal
event and just checking if it's the owner or not, etc.
I want to be able to send an event to a single instantiation of a prefab,
across all clients-not every single instantiation of that prefab.

I hope this example makes more sense, really sorry about the confusion that seems to keep happening.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Photon RPC event to specific instantiated object?
« Reply #5 on: October 16, 2013, 01:41:32 AM »
Hi,

 I am really sorry, that still doesn't make any sense at all... I am getting paranoid now...

Can you make a use case using proper identication? User A on machine A, User A on Machine B, User B on Machine B, etc etc, then we will lift any vocabulary issues.

what I understand so far is:

User A collides on Machine B ( but not on machine A) and you want to send an event but to whom? User A on Machine A and only that?

bye,

 Jean