Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

event system or unity actions with netcode

Discussion in 'Multiplayer' started by firebird721, Mar 14, 2023.

  1. firebird721

    firebird721

    Joined:
    Jun 8, 2022
    Posts:
    101
    i am trying to wrap my head around how to use events int making my game multyplayer

    i tried checking if the events are neing called somewhere - does anyone listens too the tem - i could find any listenter that hears them

    i put the line - EventsManager.OnPlayerIsDead(NetworkManager.LocalClientId);
    in some places but non of them got listend too..

    how can i work with events and multyplayer in a good way?


    public static class EventsManager
    {

    public static event UnityAction<ulong > PlayerIsDead; //its going only to the battle system

    }

    private void player controler()
    {
    if (!IsServer)
    return;

    case "Player":
    {
    EventsManager.OnPlayerIsDead(NetworkManager.LocalClientId);
    EventsManager.PlayerIsDead( clientId);
    }

    }
    [ServerRpc]
    void killPlayerServerRpc()
    {
    EventsManager.OnPlayerIsDead(NetworkManager.LocalClientId);

    killPlayerClientRpc();
    }


    [ClientRpc]
    void killPlayerClientRpc()
    {
    print("fjvhfjk");
    myPlayerUI.UpdateHealth(0);

    this.gameObject.GetComponent<ShotCollisionDamage>().enabled = false;

    EventsManager.OnPlayerIsDead(NetworkManager.LocalClientId);
    }