RPC function get called when no RPC

Sorry for my bad English, but this is the problem that I met.

I have a script called PlayerHealth.cs and is attached to my character. There is one RPC function in this script.

This function is called by another script (Fireball.cs). The fireball will hit player and deduct their health. This is the trigger function of the fireball.

This works fine when the fireball is hit at other player. Outputing

"Hit enemy at (0, 0, 0)"

"Health left: 90/100"

However, I don't know why when the fireball hit my own character, which is supposed to be ignored by the other.GetComponent<PhotonView>().IsMine, my character takes the damage. Not only that, the two Debug.Log did not output anything and only output

"Health left: 90/100"

when the fireball hit my character. It is so strange as the "Hit something" debug will always output first if the fireball hit something.

Then, I tried to debug for a very long time and still can't find the problem, so I think to comment out the RPC call first.

What SURPRISED me is that even though the RPC call is being commented out, the FIREballDamage function still runs!!!

"Health left: 90/100"

is also being output.

I read through and find through all my scripts. Only this fireball.cs has the RPC call, so I'm really confused why the function run itself when no one is calling it.

Please give me some advice. Thanks very much.


  • We don't really debug game specific logic but if we should take a peek, upload the full fireball.cs.

    Keep in mind that OnTriggerEnter() runs on all clients. Every single client which simulates this situation may call the RPC if it's not "my" fireball. Imagine a 16 player game where 15 players call the RPC due to this OnTriggerEnter. You probably want to turn this around and check if someone else's fireball hit your own character.