Problem syncing life

Hi,

How can I sync the life of the players across the network and display only the life of the player i control locally?
I have a playerBehavior and a bulletBehavior.

In the payerBehavior I have this code for syncing the life.
And in the bulletBehavior this code, to deal damage when hitting other players with bullets.

1. This isn't working as expected. Only the first player can deal damage, and then damages himself by shooting the other player. What am I doing wrong here?
2. Where do I have to instantiate the EnergyBarPrefab? In the OnSyncedStart only things that are going to by synced are assigned, or?

Thanks, John

Comments

  • Hi @John05,

    When there is a collision both machines will detect that, so a player should get hit in every game client and its life should reduce too (synced across network). But I can take a look at your project to better check if there is some problem in TrueSync or maybe you are doing some mistake.

    About point #2 you can instantiate a information prefab (as I think it is the EnergyBarPrefab) in default Awake/Start methods.
  • @JeffersonHenrique Thanks for the clarification. And that would be great, I'll send the project to you via PM, as I wasn't able to fix it yet on my own.