Announcement

Collapse
No announcement yet.

Getting player controller in multiplayer

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • replied
    Event AnyDamage is actually only server-side if you notice the server-icon on it.
    If you make Health RepNotify then the clients will get a function call whenever the Health is updated which you can use for updating UI etc.
    Again if you are using a Pawn then the clients can update their UI when OnRep_Health gets called but only if IsLocallyControlled is true unless if you also want to see the other players health.

    Leave a comment:


  • replied
    Originally posted by GarnerP57 View Post
    First of all Health calculations should only happen on the Server. You can use the macro SwitchHasAuthority and on the Authority flow is where the server-side is.

    Assuming you're using Pawns (or Characters) for your players then (still on the server-side Authority) when the player dies the server can call GetController on the Pawn and this will give you the PlayerController for that specific player. The server can then call a RunOnOwner event on that PlayerController or whatever you want.
    Ok thank you for the reply. Just one question, how would I use Health on the server side for multiple players. The AnyDamage Event seems like it's for client side... Would I need an array of names and integers for the health on the server side and then how do I set those when a player is damaged? Thanks.

    Leave a comment:


  • replied
    First of all Health calculations should only happen on the Server. You can use the macro SwitchHasAuthority and on the Authority flow is where the server-side is.

    Assuming you're using Pawns (or Characters) for your players then (still on the server-side Authority) when the player dies the server can call GetController on the Pawn and this will give you the PlayerController for that specific player. The server can then call a RunOnOwner event on that PlayerController or whatever you want.

    Leave a comment:


  • started a topic Getting player controller in multiplayer

    Getting player controller in multiplayer

    Hi,
    I'm developing a game just for fun. It's supposed to be a kind of FPS game, so there is health and guns. While I was testing the multiplayer, using pain inflicting zones to test damage and death, in single player, it worked perfectly (if health < 1 then remove player create loot box w/ inv contents etc.). However, when I tried multiplayer, if a client connected and died, then the host would die instead.
    My blueprint is like this. OnDamage -> Health = Health - Damage -> If true (Damage < 1: destroy actor, make loot box, show death screen).
    I am using the getplayercontroller and getplayercharacter to get the player who died, but since it is set to index 0, it will return the host all the time. Any way around this or do I have to re-do my system? Thanks!
Working...
X