bullet owner

Options
hi everyone :) , I would like to have a kill count on my game,I know how to do it, I have to know who shot the bullet,it's right? but the documentation says it is better not use a photonview for each bullets,so.. how can i get the bullet shot owener? thx

Comments

  • hillmatic
    Options
    RaiseEvent?
  • Yerzay
    Options
    You can just pass photon view id, and check if bullet killed. If bullet killed, just pass this owner ID and then call PhotonNetwork.GetPhotonView(photonViewID), for example.
  • hillmatic
    Options

    it was what I was trying to say, but in the official documentation it says this...Most games will never need more than a few PhotonViews per player; one or two for the character and that's usually it. If you need many more you might be doing something wrong. For example, it is extremely inefficient to network instantiate and assign a PhotonView for every bullet that your weapon fires, instead keep track of your fired bullets via the player or weapon's PhotonView via RPCs.
  • Yerzay
    Options
    You're wrong.

    " it is extremely inefficient to network instantiate and assign a PhotonView for every bullet that your weapon fires"

    It means, don't attach photon view component on bullet.

    I didn't mean it.

    Just make bullet script and add it to the bullet prefab. In this script, make int called ownerID. When you instantiate bullet, just pass photon view id there.

    So, bullet prefab has bullet script, which contains int called ownerID. When player shoot, just grab his photon view and pass his ID to this script. When bullet killed player, just grab bullet script and read ownerID from there.

    And when you have ownerID from bullet script, just find photon view and his game object by PhotonNetwork.GetPhotonView()
  • hillmatic
    Options
    aah ok im an idiot sorry hahahaah thank you very much