How to make PUN object only react to local physics?

Options
I have a multiplayer game that is essentially multiple single player games playing at the same time with player positions being sent between clients as "ghosts". By that I mean they should not interact with any objects on other clients.

So let's assume there is a cube on one client that is in a different position on another client. (It is not a photon viewed object). The local player should interact with the cube's rigid body. Any non-local players should not.

What is the easiest means to set non-local instantiated object to not be physics objects.

Comments

  • Spektre
    Options
    Rereading my initial post to make it more clear, the player is a rigid body physics object locally, However, I wish it to be a non physics object on the clients and react only to the position updates received through Photon from it's client.
  • Hi @Spektre,

    not sure if I understood this correctly, so please correct me if I'm wrong. As far as I have understood you should be fine by using rigidbody.isKinematic = !photonView.isMine; in the object's Awake or Start function.
  • Spektre
    Options
    Thanks for the replay Christian

    Hi @Spektre,

    not sure if I understood this correctly, so please correct me if I'm wrong. As far as I have understood you should be fine by using rigidbody.isKinematic = !photonView.isMine; in the object's Awake or Start function.

    I have tried this previously, but the non local player still affects objects.

    Picture a teeter totter with no Photon view, however it does have a rigid body. It starts with the left side down. (both in the local scene and non-local scene). A non-local player walks up the teeter-totter to the right side.

    My desired behavior is for the non-local player to have physics operate on his scene and have the teeter totter (and he on top of it) drop as he reaches the right side.

    Locally, I would see the player pass through my teeter tooter that has not moved as he falls. He would not have affected my teeter totter.

    My next try will be to remove the rigidbody from the player completely and then add it through script to the local player at runtime, but that will make some headaches as my nice reference to the rigidbody will be gone from the editor.
  • Have you tried to enable / disable the attached Collider according to the photonView.isMine condition?
  • Spektre
    Options
    I was able to achieve the behavior I desired with custom physics layers. Thank you for the help.