Navmesh not syncing on clients

Options
Hello :) - I have a Photon project with a terrain and (up to) 4 players and several NPCs.

The players sync properly. The NPCs, however use a navmesh agent. These NPCs have collision triggers and if any player (with tag=player) comes inside the trigger, the NPC runs away from that player.

I have added Photon View and Photon Animator View and Photon Transform View to the NPCs (like I have on the players)

If the player that logs on first approaches the NPC, it works as expected, it runs away and both players see it moving away and the animations...

However if the client that joins second approaches the NPC, it stutters and doesn't move from their perspective. From the first players point of view when the second player initiates the trigger, the NPC does nothing.

The players always sync well for both, but do not use navmesh agents.

Is there some other consideration when using navmesh or might I be missing something? Any help is appreciated!

Thanks!

Best Answer

Answers

  • Hipshot
    Options
    HI - Thanks much for getting back!

    Yes. I am picking a spot that is opposite to the direction of the player and setting that as the navigation target. I suspected ownership, and tried setting ownership to takeover in the Photon View component, which didn't seem to have an effect.

    Looked over your Ownership demo - think I am getting a better understanding.

    The owner of the NPCs appears to be the first player in the room. His Photon View controls all of the other NPC photon views. So , if he triggers the NPC, it picks a patrol point, moves towards it and the Photon Views sync.

    In the second case, if the second player to join triggers the NPC, there is no way for the first player's scene (which controls all NPC Photon Views) to know what has happened. This first player's scene continues to control the Photon View, and thus the second player sees stuttering as the NPC tries to move, but the first player's Photon View is bringing it back to its original position.

    Is this correct?

    Any idea why did setting ownership to 'takeover' in the Photon View component did not work? At what point does it 'takeover?' It seems like this would need to happen when it is triggered and controlled via a script?

    I like the RPC route, but also trying to understand ownership. I have some more complicated NPCs planned that will shoot projectiles, etc.


  • Hipshot
    Options
    Quick follow up - I think I get this now. So if you set an object to takeover - any game object can take ownership via its script. Fixed means only the first client (in the case of scene objects) or the client that instantiates it will always be the owner. Request is similar to takeover, except the client that owns it must grant the request.

    Thanks for the prompt reply. https://www.youtube.com/watch?v=ozBmZ9FoN_o&list=UUFnFXCZuob4ffmc014e07zw this video was helpful for me, in case others can benefit...