NavMeshAgent [Syncing only agent Destination gives inconsistent results]

Options
Hey guys,

Currently I am developing a game where I spawn units which are following way paths. I sync with RPC calls (which RPC is a coroutine) the agent destination (the next way point on the path). In addition, I have on the coroutine (the RPC call) check if there are enemy units in radius, if there are the next agent destination is the enemy unit. I have limited the FPS to 60 for both clients and there are discrepancies in unit locations (difference of a few metrical units, not that much but still there is unsync between clients).

How would you advise me to move my nav mesh agents so there is no difference between clients' units positions?

Comments

  • [Deleted User]
    Options
    Hi @HeadlessFly,

    when the second client receives the information about the next way point on the path for a certain object, this object has already been moving for a certain amount of time (difference between sending and receiving this information) on the first client. So you basically would have to apply some sort of Lag Compensation.

    In short: when receiving the new information you have to calculate the amount of time which has elapsed between sending and receiving. With this time information you can calculate the position, the object might have on the other client and apply it on the local client as well.

    In theory this should work, however I'm not sure if it does practically as well.