Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved Get Client from Collision

Discussion in 'Netcode for GameObjects' started by geefuoco, Jan 6, 2023.

  1. geefuoco

    geefuoco

    Joined:
    Jan 6, 2023
    Posts:
    2
  2. RikuTheFuffs-U

    RikuTheFuffs-U

    Unity Technologies

    Joined:
    Feb 20, 2020
    Posts:
    440
    Hi @geefuoco , what are you using to detect the collision? is it OnCollisionEnter? The fact that your game is multiplayer doesn't change how you apply damage, as all of this should be handled server-side.

    On the server you just need to change the NetworkVariable that represents the health of a specific player when you damage it, and it will be synchronized to all clients.
     
    geefuoco likes this.
  3. geefuoco

    geefuoco

    Joined:
    Jan 6, 2023
    Posts:
    2
    Thanks for your reply. I managed to solve the issue already. The problem was I was using RPC's instead of NetworkVariables for applying the damage, so once I switched it was fixed.
     
    RikuTheFuffs-U likes this.
  4. CasioGoat

    CasioGoat

    Joined:
    Jul 5, 2023
    Posts:
    2
    Hey Geefuoco, I am new to unity as well I wanted to see how you were figuring out which player is being collided with. I know you can return the player tag, but does that have information about the clientID? how do you know which player to apply the damage to.