Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

event system or unity actions with netcode

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

  1. firebird721

    firebird721

    Joined:
    Jun 8, 2022
    Posts:
    90
    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);
    }