Adding Player Score When You Get A Kill

Options
I am trying to make it when a player gets killed they send a message to the player who killed them to add the some points. So far I have it so the raycast sends a message to apply damage and it also sends the players name but how do I then get the player send a message back to the player who killed them to give them points.

if(hit.transform.CompareTag("Player")){ } hit.collider.GetComponent(PhotonView).RPC("hit", PhotonTargets.All, 30, PhotonNetwork.player.name); PlayerPrefs.SetFloat("Points", PlayerPrefs.GetFloat("Points") + 10); }


@PunRPC function hit(amount, name){ health -= amount; }

I have defined all the player.name variables and stuff and I know it is working I just need to know how to send a message back. I know this is in javascript but I will be happy if you can tell me how to at least do it in C# and I will convert it to JS.

Sorry if this was confusing I am very tired, I've stayed up for hours trying to work this out.

Comments

  • Lorcan
    Options
    OOPs made a mistake, if(hit.transform.CompareTag("Player")){ }
    Is supposed to be if(hit.transform.CompareTag("Player")){

    I accidentally changed it while copying it across.
  • vadim
    Options
    In C#, PunRPC methods may have optional last parameter of type PhotonMessageInfo . It has 'sender' field which can be used to specify target player when calling RPC back.