Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Third Party how to deal damage properly/better using PUN 2

Discussion in 'Multiplayer' started by ShadowFlame45, Mar 18, 2023.

  1. ShadowFlame45


    Nov 6, 2021
    for my game, i am storing health as a custom property. whenever a bullet collides with a player, it finds the player's photon view, takes the current health, then subtracts by a certain amount of damage.

    this works for most types of guns, but for guns with multi shot, like a shotgun, it won't. all of the bullets take the same original health, then all subtract by a certain amount of damage, essentially causing the damage to equal to one bullet. this problem is most likely caused by custom properties not updating with in a frame.

    is there a better way to approach dealing damage, or is there some way to force update custom properties?
  2. tobiass


    Apr 7, 2009
    I don't know if it's a common approach to have shotguns shoot individual bullets...
    One client should calculate the damage. You could collect damage for a frame, then after that is resolved, send all damage at the end of the frame.
    In doubt, have a local variable to store the health, work with that and update the custom properties accordingly, several times a second.