Instantiating effects etc

Hi guys,

im trying to convert my shooting mechancis to photon so user can shoot and kill each other i got the health rpc to sync well and player dies but when it comes to effects,bullet holes and hit effects i cant convert the code properly here is the code

PhotonNetwork.Instantiate(holes[Random.Range(0, holes.Count)], hit.point, Quaternion.FromToRotation(Vector3.up, hit.normal));

now i know it has to be in the resources Folder and set as a string but thats where dilemma comes in..


thanks in advance for any help

Comments

  • Hi,
    Effects, bullets and holes are examples of things that should not be instantiated or synchronized via network. It's too expensive to do so. Instead, create and handle them locally basing on network-synchronized game state and events.
    Holes may be an exception if it's important to show them for new joined clients. But again network-instantiating is too expensive. Use buffered 'hit' PRC's to create them locally.
  • OK so if i understand you correctly..(sorry networking is still somewhat new for me) i should basically make that call into a RPC?
  • Yes, use RPC's for lot of tiny objects.
    For instance one client (usually shooting) detects hit and sends 'hit' RPC to others (or separate 'effect' and 'hole' RPC's if 'hole' should be cached). In RPC handler each clients creates decal or spawns effect.
    You need 'shot' RPC for bullets only if bullets are visible. There is nothing to do for clients in 'shot' handler otherwise.
  • In general: You should always try to infer as much "follow up" actions from any sent message as possible.
    If you send a "shot", you don't have to send "create bullet" and you also don't need to send "create a splat where bullet hit wall".
    Instead: You know how a bullet is flying in general and that it creates an effect when it hit a wall.
    To make sure all clients have the same values for hitpoints and the leaderboard, one client should detect if a bullet hit something and then send an update if a player was hit (instead of something immovable).