Variations on this question have been asked, but I couldn’t find anything close enough to my setup to help me.
I’m prototyping a multiplayer, vehicle-based, third-person shooter in Blueprint (local multiplayer only for now) in Unreal 4.2.1. I’ve got functioning player controllers, ammo pickups, projectiles, etc., and now I’m trying to figure out how to handle indexing/IDing of multiple player controllers. There are two specific issues I’m trying to resolve:
1 - Our game’s HUD has health and ammo indicators that need to be unique for each player. Right now I’m using functions built into my player controller Blueprint to cast them to the HUD, where I use a series of conditionals to check the player variables and display the appropriate textures on screen. They’re fully functional when it’s just me driving around the map, but now whenever I shoot another instance of the character Blueprint, it detracts a health counter from my HUD. I’m pretty sure the reason is because the instances of the character Blueprint are all pawns/whatever the correct term is of the main player controller class, so I tried adding a proper second controller via the gameplay Blueprint. No luck, and while everything else works correctly, it still alters my HUD when I shoot another player controller. How can I make it so that my HUD is tied exclusively to my player controller?
2 - I have the player controller fully set up for mouse and keyboard controls and a 360 controller. Again, it all works fine for one player controller, but now I don’t know how to control the second (or third or fourth, when that time comes). For the immediate future, I’m trying to make the mouse and keyboard controller Player 1 and the 360 controller control Player 2. The control setup is pretty sloppy for right now (this is a pretty sloppy prototype, TBH), with movement controls being defined in Inputs in the engine settings and actions being defined in the character Blueprint, so I may need to go back and rework those depending on the situation.
This is being done for a prototype that’s due for a class tomorrow, so temporary workarounds that might not work for more than two players are acceptable for right now, though I’d prefer to get it set up where I can add more players.
Not having to worry about indexing would be ideal, but I don’t have the first clue about how to do that with my current setup. Where does Get Owning Pawn plug in, do I still need variables from the Player Controller, if not then how do I access the necessary variables, etc. How would I go about doing that?
Ok first of all blueprint nodes with “f” icon are belong to classes, that why most of them has Target input, except the static functions, the “Target” is a object on which you want call function, if blueprint is that class or based of that class yo don’t need to plug anything there, it will use object that it inside in, do if you place it in HUD it will just woork without pluging Target. Also most nodes representation of functions in C++ and that why you can find them in API reference.
I see you already interacting with HUD toghther with casting, so i don’t see how you would not able to figure how to access PlayerController and Pawn from HUD in same way using functions i showed you, assuming you using Controller and it possess the Pawn.
One think that you might missed is that you can access varables from any object by druging and droping the blue object wire from the pin. In context menu you should have “Varables” category and there should be Get or Set nodes for specific varables, this is only way to access them. This way you can access varables from your PlayerController and Pawn and direcly display them on HUD without duplicating data in HUD by another variables and send them from other blueprints. Set/Get varables will also have “Target” input