Feature Request

I'm implementing projectiles in my game and I would like the projectiles to have a finite lifetime even if they never hit anything (to prevent object overload)

Unity's Object.Destroy has an overload that takes a float t as a parameter for the time delay before destroying the object, can we have the same feature in PhotonNetwork.Destroy?

Comments

  • We can take a look at this, yes. Depending on how much effort this means we will put it on the roadmap.

    Usually, you don't want a separate view per bullet. From what I understand, you would try to handle all bullets through one view.
    But that's only repeating what I learned second-hand. Maybe someone else chimes in.
  • Really? I thought each PhotonView can only observe one GameObject. You can have multiple photonViews per game object, but I've never never come across 1 PhotonView observing multiple objects.
  • (semi-offtopic: Do you really need to instantiate bullet GameObjects that literally fly trough the scene?)

    I think it's quite an overhead to use Instantiate() and Destroy() for every bullet. You could just send a single RPC per bullet instead. So the player that shoots calls the rpc FireBullet per bullet. FireBullet is run on all Players (particles + sound is played and possibly a line renderer, etc.). Then, only the masterClient would run a raycast to decide if actually anything was hit (or have the local player raycast his own bullets? Up to you).
  • It depends on your game, but if scenarios like multiple continuously firing machine guns each shooting about 10.000 bullets per minute, you will get into serious performance problems, when synchronizing the positions of all bullets between all players, even with very short lifetimes.
    Actually any info besides from an actual hit is only needed for weapons like guided missiles. For normal bullets of heave damage low frequency weapons you should just send creation-time position, acceleration, speed, direction and bullet-type (maybe even only creation-time, position, direction and bullet-type, if the other two will always have the same starting values), when initially creating them and calculate their movements locally on the receiving clients, as it will always. For low damage high frequency weapons it even makes sense to simulate no bullets at all, but just send an info like "player 1 starts machine gun fire from position x in direction y with munition-type z." and "player 1 stops firing" and calculate hits on server or master-client, without creating actual objects for bullets, as when a car is hit by 200 bullets in a few seconds, no one can tell, if it had to be 199 or 201 anyway.
  • I don't think the time-overload on PhotonNetwork.Destroy makes sense as it's really game-logic. Adding timers to PUN feels illogical to me. Feel free to convince me otherwise though.