Search Unity

Third Party Photon RPC function get called when no RPC calling

Discussion in 'Multiplayer' started by ZiLeKam, Apr 16, 2023.

  1. ZiLeKam

    ZiLeKam

    Joined:
    Apr 23, 2022
    Posts:
    3
    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.
     
  2. ZiLeKam

    ZiLeKam

    Joined:
    Apr 23, 2022
    Posts:
    3
    I restarted my laptop and it's fine already, thanks.