Hi, I’m stuck with this right now. I’m making a multiplayer game and I want the player who’s joining a game to know how many players are currently in the session. What I’m doing is when looking for sessions to join, I create a button for each of them so the player can click and join any session, but what I want is to hide or not create buttons for the sessions that are full, so that’s why I need the number.
EDIT: I haven’t noticed this was in C++ section, not in Blueprints at first glance.
Leaving answer here in case someone else has use for this. Apologies for wrong posting.
Type “get player array” in your GameState blueprint. It should give some info about connected players.
In a project I work on however, I created a (replicated) PlayerController array in GameMode and using Event OnPostLogin to get info for each connected player. I spawn a camera pawn each time this event is fired. I “push” the display name of the controller to a TextRender component that is a child of the camera pawn. Also I make sure that the last logged in controller (player) possesses the latest spawned camera.
Anyway, I am going out of topic fast here
The thing is, I track connected players via a replicated PlayerController array that I’ve created in GameMode class.
Check out the screens, my “build” may not be the best way to accomplish this. Heck, it may have flaws even
Also don’t forget to track logging out players (deleting them from array) via Event OnLogout in case you go this way.
Thank you for your answer but I think this is not what I’m looking for. What I want something similar to what the MultiplayerShootout example has here:
Essentially if the session found is full, like in this example, I want to not create the button. The problem is that I’m handling all this through C++ and I can’t find the equivalent to this node basically:
Well, if you have a C++ project, you can typically right-click a blueprint node and ‘go to code’.
However, if you simply hover over the input for Get Current Players, it says it takes a Blueprint Session Result struct.
Ctrl+Shift+F for that returns FBlueprintSessionResult found in FindSessionsCallbackProxy.h
Alternatively, you could Ctrl+Shift+F for GetCurrentPlayers, which takes you to the same file, a little further down. In the implementation file we find: