PUN Unity PC C# Vehicle Questions

Options
I have "Vehicles". Horses/boats, carts, etc.

I have worked out all of my getting on and off bugs, them despawning when the spawning player leaves, all that is worked out.

My issue is, if somebody is in/on a vehicle, when a new player joins they can't see the vehicle. and they get bugged out from existing, even if someone gets off of it.

I currently change ownership of the photonview on the vehicle when a player matching the ID of the one entering the trigger (so there is no confusion of who hit the enter/exit button). Which works, except when a new player joins, It receives the RPC from the wrong photonview ID (since it no longer exists).

I've tried buffering the RPCs, to all, others, and via server ,etc. I'm just running this in a single Cloud room for prototyping.

Does anybody know of a better way to do this? If anyone would like to help that would be great ;)

Comments

  • vadim
    Options
    I currently change ownership of the photonview
    Changing of photonview ownership is not supported in PUN.
    Common practice is that all shared items are owned by master client. Who is on what vehicle should be implemented as property of player or vehicle.
    What does not work if you take this approach?
  • J_Troher
    Options
    I have found a way to make this work yesterday, by making the master spawn it as a scene object and changing the owner ID when somebody gets in/out of a vehicle. This has actually turned out to work quite well.
  • Tobias
    Options
    The changed ownerID is not being synced with users who might join after the change. New players will have a corrupt state.
    You can possibly do something based on a public property like the Pickup Demo does. The owner of a pickup item is stored in a property that's readable by everyone - including joining players.
  • J_Troher
    Options
    Yeah. I ran into that problem.

    What I do is bufferviaserver the change of ownership. and clear said buffer when a player exits the vehicle. This does not need to be buffered, since it is being reverted to its original scene owned state. It seems to work quite well. Though I only have 4-6 people to test it with.
  • Tobias
    Options
    I will try to revisit the topic soon and see if I can support it.

    Until then: As long as it's working for you, it should be fine.
    Glad you could get it done :)