See other players interact with environment

Options

Hi,

I am developing a multiplayer golf game. The balls each have a photonview attached and the position is synchronized automatically by Photon. The problem with this is that if another ball than my own interacts with the environment, it is only registred locally since colliders don't trigger when moving objects transforms.

What would be the best approach to handle interatctions with environment that should happen globally?


  1. I can instead of syncing position sending the shot direction and power over RPC and make the shot on each player. Will this be okay or can weird things happen in Unity engine so that the balls gets out of synch positionally, for example bugs that happen when you go over collider edges?
  2. Send all interations happening in OnTriggerEnter over RPC to all players. This gets a but messy and there will be lots of RPC calls this way.


Does anyone have advice on how to progress? It is hard to find information about the best approach to this.

Answers

  • Tobias
    Options

    Unity is not deterministic, so yes, sending an RPC about a shot may result in odd results. But .. you probably have to work on such odd cases anyways, because this is also how a single player would solve the shot.

    I think sending an RPC for the shot is OK.

    You may want a way to check, compare and sync all final positions of objects. In deterministic engines, you'd use a checksum but this won't work if the floating points are not precise / deterministic. You could possibly trace which objects were affected and then send their final situation, so everyone could update their final state...