How do you get a reference to something that is in the scene outliner? Especially after the game has started? I am wanting to get references to the player objects that spawn from “Player Start” after the game starts. I am trying to make a from a HUD class but it seems like I need a reference to the player first to call the HUD event somehow. Also I don’t even see why the player start spawns 2 objects camera manager and player controller. Where do I find that these are instantiated from “Player Start”?
Also how do you get references to other blueprints? Call a blueprint from a blueprint? Access other blueprints from another blueprint.
You can use the getter functions Get Player Controller and Get Camera Manager to grab the current instances of those classes. Right click in the Blueprint and type “player” in the search box and those should show up. Then you can drag off the Get Player Controller to access the HUD.
To call a Blueprint from another, check out Blueprint Communications:
And Blueprint Interfaces:
Hope that helps!
It doesn’t seem to be working, I don’t understand HOW it connects to the player? There aren’t many outputs for the get player also. I dont know how to connect them up because I first don’t understand how its finding MY player.
For instance pressing F is doing nothing right now, I think its because its not connected to the player. But input doesn’t allow me to connect from a player first.
Yeah I did, I’m using the blank project with starter content checked by the way. But i noticed something After doing that. It shows new options for creating blueprints that weren’t there anymore under the category game blueprints.
First, let’s take a step back and make sure that your custom HUD is being used when you play the game. To do this:
Create another Blueprint and pick Game Mode for its parent class. This will hold custom settings for your game, including the HUD class.
Open that Blueprint and go to the Defaults tab.
Where it says “HUD Class”, pick your custom HUD from the dropdown.
Save the Game Mode Blueprint.
Go to your map and open World Settings (Globe button in the menu bar)
Find Game Mode and set Game Mode Override to the Game Mode Blueprint you just created.This will tell that map to use your custom settings when you play.
*You can also set the Game Mode in Edit>Project Settings>Maps&Modes>Default Modes>Default GameMode. This will set it as the default for any game map in your project.
With that set, You can delete everything in your image above except Event Receive Draw HUD and Draw Rect. You should get a rectangle drawn on the screen. Let me know how that goes.
Hmm…are you sure you compiled and saved both the HUD blueprint and Game Mode blueprint? I’m trying to figure out what else could be missing here. I just did the steps above and it works.
In your Hud class, try changing the Draw Rect color. Recompile and save it. See if it shows up then.
Glad it worked. That’s a weird bug. I’ll have someone check that out.
Here’s a document about the game framework and how the classes work together:
But I agree. We should have a tutorial on how to set up the blueprint classes if we don’t already. In the meantime, it may help to look at some of the sample game content to see how it’s put together. And of course feel free to ask if you run into problems.
Also, take a look at the Blueprint_HUD map in the ContentExamples project for an example of how to set up a HUD with Blueprints.
Yep that worked, Thanks. But how was I supposed to know all the stuff you listed to do. Is there documentation on everything you need to get blueprints working? I wouldn’t have figured out to make a game mode class and then set it in the world settings.
Yeah I actually did take a look at that Blueprint_Hud. But calling anything from it in a blank project wasn’t working because I didn’t know what you told me to do until you told me. As in creating a gamemode blueprint and setting the gamemode override to my gamemode class.