How to damage others but ignore self

Options
Hello there! I really like Photon so far, but I'm pretty new to it so I have some issues at the moment in regards to specific players taking damage etc.

So the way it currently works is that every player is syncing their health with this:
void Update()
    {
        if (!m_PhotonView.isMine)
        {
            playerHealth.setHealth(health);
        }
        else
        {
            health = playerHealth.getHealth();
        }
    }

    public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.isWriting)
        {
            stream.SendNext(health);
            stream.SendNext(anim.GetFloat("m_MoveSpeed"));
        }
        else
        {
            health = (int)stream.ReceiveNext();
            anim.SetFloat("m_MoveSpeed", (float)stream.ReceiveNext());
        }
    }
That seems to work ok, but what I want to do is for example to have one player cast a meteor, but I only want the meteor to be able to damage all players except for the one who cast it.
I can't seem to figure out a way for the meteor to not damage the one who cast it. Right now I'm instantiating it with PhotonNetwork.Instantiate and then the meteor has a script on it that basically just checks everyone it collides with and deducts the damage from the HP.
How would I make it so that the meteor ignores the player that cast it fully? I've tried with PunRPC but no matter how I wrote it I couldn't get it to work properly. It would either damage the wrong player or all players.

If you need more information let me know. I really hope someone can help me with this as I haven't been able to search my way out of it :(

Comments

  • Novez
    Options
    Alright so I got it to work by giving each player an ID in a manager each of the player prefabs has.
    Whenever I spawn the meteor I give it an owner ID as well, which is the same as the player that cast it, and then I check in the collision if the owner id is same as player ID, if they are, it will not damage vice versa.