Get Controller ID
This question seems so stupidly simple I was amazed I even needed to ask it. I'm working on a game that has local multiplayer. We have a functioning Blueprint set up to spawn the appropriate number of players, and on each "Create Player" function, there is an input called "Controller Id." I assume this is the player's index number in the game. My question is how I can get that ID number within the player blueprint class. Or alternatively, define an index value manually in the multiplayer setup Blueprint and cast that to each player.
Our game has a HUD that has elements such as health and ammo that must be assigned to each player manually. We have the input for those things ready to go, we just need a way of accessing the player's index number to plug it in. So a more general version of this question would be how do I get an individual player's index?
asked Oct 10 '14 at 11:32 PM in Blueprint Scripting
Use "Get Owning Player Controller" in your HUD Blueprint to get the correct player controller associated with that HUD.
From there on you should be on the right track with the rest of your Blueprint.
Also: You should seriously update to the latest version of UE until a few weeks before your release. The engine is still heavily being worked on and a lot of bugs get fixed with every new release.
answered Oct 23 '14 at 03:13 PM
"The ID of the controller that the should control the newly created player. A value of -1 specifies to use the next available ID" (didn't know that myself :p and thats why i always recomand to look in to API refrence even to blueprint users)
You don't need player index to associate HUD with PlayerController, they will refrence eachother automaticlly
From HUD: https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/GameFramework/AHUD/GetOwningPlayerController/index.html or even: https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/GameFramework/AHUD/GetOwningPawn/index.html
So you don't need to play with ids just set HUDClass in PlayerController and engine will set up everything for you
answered Oct 11 '14 at 01:17 AM
Okay, so I've figured out (through much headache and tedious research) how to call the player class variables directly from the HUD class instead of casting them from the player to the HUD. Basically it involved making those variables public and then doing a cast in the HUD blueprint, but because I had to cast it, I'm running into the same problem.
Now instead of changes to any player affecting only Player 1's HUD (which is what it was doing before), changes to only Player 1 affect everyone's HUD. So actually it's more like exactly the opposite problem from what I had before.
The source of the problem is that in order to get those variables into the HUD class, I seem to HAVE to cast something, somewhere. And whether I'm casting to the HUD blueprint from the player blueprint or to the player blueprint from the HUD blueprint, it still requires a Get Player Character function, which still has that index pin, which is still set to a fixed integer value.
So I either need a way to get the player's index, or a way to move the variables from the player class to the HUD class that doesn't require any casting (or at least that doesn't require use of Get Player Character). Does anyone know a way to do one of these things?
Your going about this the wrong way. All you need to do is make the variable editable in your character blueprint by checknig the eye. Then within your hud blueprint do a cast down to the variable you want and then update your hut from that variable.
Your hud is ALWAYS going to be your local controller. Multiplayer games and dedicated servers have no concept of anything that happens on HUDs. They only exist locally on the player that owns then. The other players can not access other players huds ext.
Here's an example of getting a index of inventory items thats contained within my character blueprint doing this all from a HUD.
answered Oct 12 '14 at 02:26 PM
Does anyone else have any other suggestions at all on how to get this working?
answered Oct 13 '14 at 11:09 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here