playMaker

Author Topic: Quick question - change a photon objects 'owner'?  (Read 11939 times)

Swift_Illusion

  • Playmaker Newbie
  • *
  • Posts: 41
    • Midnight Tinkering
Quick question - change a photon objects 'owner'?
« on: October 10, 2013, 01:49:35 AM »
Hello,
I'd like to know how to change the 'owner' of a photon network object,
so that I can transfer the ownership of an object between players.
I've taken a look through the Network and Photon playmaker actions,
but I can't seem to find anything relating to ownership changes,
only getting information about an owner/checking who owns an object.
For example when a character collides with an object I'd like to change the ownership to that characters client.
I'd greatly appreciate a response in regards to this.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Quick question - change a photon objects 'owner'?
« Reply #1 on: October 10, 2013, 02:58:12 AM »
Hi,

 I don't think you can. I would ask on the Photon Forum to begin with, if that's possible indeed, I'll look into it.

Can you describe what you are after? You would like the user to start controlling an object? to do this, I would make that object NOT with a photon view, and have an invisible photonview controller that you instantiate as the user collides that you then tie to that object. then it works, because your object is inert and controlled by an invisible instance that you can dispose and instantiate at will based on who collides on that object. The object can be responsible to instantiate its controller, that works too, because when colliding, you'll check the collider target and you only fire an event if the photonview is owning this target.

bye,

 Jean

Swift_Illusion

  • Playmaker Newbie
  • *
  • Posts: 41
    • Midnight Tinkering
Re: Quick question - change a photon objects 'owner'?
« Reply #2 on: October 10, 2013, 08:18:32 AM »
I've been searching for a solution for synching the physics of my project,
and I've searched everywhere about synching physics with unity and photon and the majority of answers refer to transferring the 'ownership' of the object, to each player that collides with it. So it must definitely be do-able, but there doesn't look to be an action for it.

To elaborate further with a reference, it's like when instantiating the player over the network. The client that instantiated that player is the owner of that object, and you can synch the position to other clients with Photon View observing the FSM and in the other clients setting the position with lerp.
Your solution sounds like it would work, but not for a physics situation.

The reason you want to transfer the ownership is so that the player actively colliding with the object is the one driving its change, because otherwise you would keep going through objects, with the delay of sending your position to the server.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Quick question - change a photon objects 'owner'?
« Reply #3 on: October 10, 2013, 01:35:38 PM »
Hi,

 I would be very, very careful if you want physics involved in a multi player environment. The only way I am aware of that works is running Unity as a headless master on the server, so that only that running instance is responsible for the physics, all players running on their machines are simply forwarding the desired position, but only the headless unity master makes the final decision on the position based on its own physics calculation and dispatch the new position to all regardless who owns what.

 I am pretty sure there is something in between, like for example controlling everything via forces, and have on top a moderation system to readjust positions, again using only forces. which meanse everyone is running its own physics engine and the multi player environment simply synchronize the desired position as targets.

 I admit I never tried to run anything drasticly physics based, so this is only what I have seen documented and heard about... but I never heard of changing ownerships to solve physics simulation within a multi user environment.

I think you should ask on Photon forum to see what they say. You will likely get more answers with proper experience on this.

bye,

 Jean

Swift_Illusion

  • Playmaker Newbie
  • *
  • Posts: 41
    • Midnight Tinkering
Re: Quick question - change a photon objects 'owner'?
« Reply #4 on: October 10, 2013, 04:42:14 PM »
The problem is if I ask I'll just be sent back here because it's related to Playmaker and I wouldn't know the first thing about trying to program it manually.
I've found some simple looking code though for a method to switch the owner by an exitgames staff member.
The second option shown here.
http://forum.exitgames.com/viewtopic.php?f=17&t=1387#p6589
Do you know how this might be used as a custom action?
(Also the 'TODO' mentions "This code works fine if we have a game where no other players can join while a game is in progress.", that's fine for my type of game as new players won't be able to join after the game has started).

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Quick question - change a photon objects 'owner'?
« Reply #5 on: October 11, 2013, 01:23:20 AM »
Hi,
 
There is no need to mention playmaker here, you are looking for a higher level support. If it can be done without playmaker, it can be done with playmaker. So don't mention it, else people will get misleaded as to what the question is about. It's about the likely technics to apply to run a multi player physics project.

Your link is clear about the fact that this is not really a supported solution, and it doesn't work in all cases. I would definitly not recommand doing this unless you find a clear documentation saying this is the way to go... ( cause I don't think it is really)

Instead, I strongly believe in the technic that I am currently using personally in my R.mote project. Which is the one I exposed in the previous post. Basically, you add a level of inderection. the object you want to control is NOT networked, it's inert. and each player has it's own controller, that you decide wether or not it controls that object.  The benefit within R.mote is that I don't expose internal logic to the SDK ( the iphone app widgets prefab used to control the app is not there in the sdk!

typically you could do this with a character, your "player" is an empty gameobject with an fsm that has a reference to that character and controls is if it's yours or not.

I appreciate it's very abstract, I don't have time currently to create a specific sample for this, but I have added this to my todos for photon related work.

bye,

 Jean

HFMgames

  • Playmaker Newbie
  • *
  • Posts: 3
Re: Quick question - change a photon objects 'owner'?
« Reply #6 on: December 19, 2015, 01:11:13 AM »
hello. How to make a transfer of rights in Playmaker? https://doc.photonengine.com/en/pun/current/tutorials/ownership-transfer

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Quick question - change a photon objects 'owner'?
« Reply #7 on: December 19, 2015, 04:43:22 AM »
Hi,

 I haven't covered this yet on the PlayMaker port, but it's on the todo list already:

https://trello.com/c/7uuBZfv8/7-photon

 Bye,

 Jean

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Quick question - change a photon objects 'owner'?
« Reply #8 on: September 12, 2016, 07:50:24 AM »
Hi,

 This is done. I am working the demo, but the feature is now available with actions and proxies updated for this.

Make sure you read the photon doc on ownership transfers, setting up the photonView properly is critical.


 Bye,

 Jean