Announcement

Collapse
No announcement yet.

How to find out which player is interacting with an actor?

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

    How to find out which player is interacting with an actor?

    I have an actor that the players can interact with, so the first thing I do is enable input on the actor when a player enters its trigger volume. Most tutorials and such that I see do something like this.

    Click image for larger version

Name:	1.png
Views:	1
Size:	62.6 KB
ID:	1162365

    I have three questions.

    1. The problem with the above blueprint, is that it is just enabling input for the player at index 0. So clearly this approach does not work in a multiplayer environment. So instead, I'm connecting the Other Actor pin to the Player Controller pin (using a cast to the Player Controller of course). I assume this will then enable input on the actor for the specific player that has entered the actor's trigger volume, right?

    2. Does Enable Input keep track of multiple players that can have input on the actor? For example, when Player1 enters the trigger volume, they have enabled input on the actor. What happens if Player2 then also enters the trigger volume? This would cause Player2 to enable input on the actor. Does Player2's "enable input" overwrite Player1's original "enable input," or does the actor keep separate track of the fact that both Player1 and Player2 now have input enabled on it?

    3. If both Player1 and Player2 have now enabled input on the actor, how do I tell which player is trying to interact with the actor? For example, if I add an E key Input node to the actor's blueprint, it just gives me a pin for Pressed and Released. I have no information to tell me which player it is that has pressed E on the actor? How do I find out which player (from the Player Controller pin on Enable Input) pressed E.

    #2
    If you are getting player controller on the client then the index will always be 0. You need to be getting it on the game instance or game mode to find out what the player controller is on the server side of things.

    To find out who is interacting with it you should direct the interaction through an object on the server that knows which player ID each person has and you could assign that as a variable when they make an action

    Comment


      #3
      Hold on, so does that mean the Other Actor pin won't give me the player controller actor of the player that overlapped the trigger?

      Comment

      Working...
      X