Hi,
I try to get the index of the player who enter in a trigger but th thread is not completed :
Is someone have the solution ?
Thanks
Hi,
I try to get the index of the player who enter in a trigger but th thread is not completed :
Is someone have the solution ?
Thanks
Hello,
I continue my research… I try to use the “Other body” pin like in documentation like this :
When my player enter in trigger the server and the client print “1”… I don’t understand why ?
Thanks
Wow… I just typed a big thing and the page just wiped it out. Ugh.
The reason that setup isn’t working is because you’re comparing an actor to a controller. The actor being returned here would be the player character, the physical representation of the player in the world. The controller you’re getting from “get player controller” is more like a remote control for a TV, used to control the device but ultimately detached and can function independently from the character. You could drag from the “Other Actor” and use a “Get Controller” node then cast to Player Controller to compare.
Alternatively, you could set up your own player index. In the Player Controller blueprint, add a “Player Index” integer variable. Then, in your Game Mode blueprint, add a “On Post Login” event. This event gets triggered when a controller “joins” the game (will happen once for each player). Add “Player Index Counter” integer variable there. When a player joins, set their “Player Index” to be equal to the counter then increment it. This will give each player controller a unique ID you can check for later.
Thanks Chumble, I try your solutions and I come back…
Hi,
I try your solution and (I think) it’s works :
Now, I have a “0” from server when client enter the trigger and “1” from client.
But my real problem is to find the player’s ID who enter in trigger so I try your solution.
Thanks
Hmmm, I’m not sure what “Get Instigator Controller” actually returns, it wasn’t what I had in mind. I think there’s just a regular “Get Controller” or “Get Player Controller” node.
Hi,
I try your second solution like this :
But when I do a “print string” in the “Event Begin Player” in Player Controller, I have only “0”… May be my “Print string” is call too early ?
Hmm, it looks to me like this should work. It might be that the Event OnPostLogin is being called too rapidly, so the second player has connected and set the “Player index 2” before the first player can trigger the increment. You could test this by adding a print to the end of the blueprint you posted here to show the value of “Player Index Counter” after it increments. I’d bet it would show “1” then “2”.
You could increment the counter before setting it to the player to ensure that it always increments prior to assigning to a player. If you set the default value of “Player Index Counter” to -1, the first player will still get a value of 0 and the second will get a value of 1.
On a related node, you can use the “Increment Int” node to add 1 to a variable and it will update the value.
Hallelujah, I’m looking for the node “Increment int” since several months…
I try this :
So I think the “Player Index” isn’t initialize… Any idea ?
Did you move the location of the increment? Here’s my crude representation of what I was talking about:
Yes, but I have the same problem…
Can you post updated versions of your game mode and trigger box blueprints? I see no reason why this value isn’t being updated.
A couple things…
In your Game Mode, you can remove that last Set Player Index Counter - it’s already being incremented previously.
In your Player Controller, you can remove that Print String to get the index. It’s possible the Player Controller’s Begin Play event triggers before the Game Mode’s “On Post Login” event, so it might be printing the index before it’s able to be set.
In your Box with Trigger, don’t use “Get Player Controller (0)” because that will always return the same player controller regardless of who triggered the box. Instead, drag from “Other Actor” and run a “Get Controller” then cast it to a player controller.
If all this still doesn’t work, I’ll be fairly stumped and might have to do some tests.
A couple things…
In your Game Mode, you can remove that last Set Player Index Counter - it’s already being incremented previously.
In your Player Controller, you can remove that Print String to get the index. It’s possible the Player Controller’s Begin Play event triggers before the Game Mode’s “On Post Login” event, so it might be printing the index before it’s able to be set.
In your Box with Trigger, don’t use “Get Player Controller (0)” because that will always return the same player controller regardless of who triggered the box. Instead, drag from “Other Actor” and run a “Get Controller” then cast it to a player controller.
If all this still doesn’t work, I’ll be fairly stumped and might have to do some tests.
[/QUOTE]
Done, but I can’t find “Get Controller” to pin at “Other Actor”. The idea is each player print his “Player Index”…
Ok, sorry about this. I hadn’t done a local multiplayer setup before and I was assuming it was largely the same as an online multiplayer scenario. It is not. The Event On PostLogin doesn’t help.
Firstly, set the number of players back to 1 under the play button. Using more than one is only for networked play.
Then, adjust your GameMode to be like the following:
Note: If you’re not using player pawns, ignore everything else after the “Create Player”, you only need that one node
When your game starts, it already creates one player controller. This will have it create one additional player controller. If you start your project, it will now be split screen to show it is local multiplayer.
On your box collision
This will get the controller ID of the player and print it. 0 for the first one, 1 for the second.
I had issues testing this fully because I don’t know how to set up input for local multiplayer but I was able to test it eventually.
Hi,
I try your solution tomorrow and I tell you…
Thanks
Thanks for your answer.
My game is a multiplayer game whith a dedicated server.
Ok but if I want to have more 2 players ?
Thanks, so there is a function to find the player ID ?
Thanks a lot for your help !
Oh, ok the thread you linked to in the first post was for a local multiplayer setup.
For each client connected to the game, they will have an id of “0”. This index is used only to keep track of the controllers connected to a single client, so like split screen local multiplayer. For online multiplayer, it will always be 0.
I’m going to start a new example project to test this in an online multiplayer environment.
Hi, thank you and I’m sorry if I trouble you with my server.
I just want to find the player who enter in a trigger and I think the best solution is to find his ID.
I try an other solution but it’s doesn’t works too so I open a new thread :
https://forums.unrealengine.com/showthread.php?127684-Problem-to-identify-the-actor-who-enter-in-a-trigger
Don’t spend more time with a new project, thanks a lot to help me.