Hey, I’m trying to insert a script in which when my character “offroad_bp” goes over an object it adds a counter, but when I try and get the player character in the widget for it I get this error
Hi Calzafy,
Try ‘Get Player Pawn’ instead.
In the context of Chaos Vehicles: OffroadCar_Pawn inherits from WheeledVehiclePawn which inherits from Pawn. (And Character inherits directly from pawn and is on the same hierarchy level as WheeledVehiclePawn)
Ive tried that but I’m having another issue as well, I followed a tutorial to input a HUD which adds a counter up when you hit an object in the game, but the HUD doesn’t even show on my screen when I play
What is the parent class of your “Offroad_BP” asset?
I think your statement about the HUD would be considered “off topic”. Try another HUD tutorial maybe? (You’d be using Add to Viewport at some point.)
How would I find out the parent class, I’m practically brand new to this so I don’t know much lmao
No worries.
When you open the BP, in the Upper Right corner you’ll see ‘Parent Class:’
My suspicion is that the Parent Class of your Offroad_BP Blueprint is just an ‘Actor’ instead of being a Pawn or Character.
Ok thanks, the parent class is “wheeled vehicle”
Ok, are you 100% sure that when you replace that ‘Get Player Character’ node with ‘Get Player Pawn’ that you still get a warning? If so, what does the warning say now?
No I don’t get a warning when I change it to ‘Get Player Pawn’ but it still isn’t showing on my HUD
Show us how you create the widget.
-
In the last screenshot - does the script run? Put a print string after the
Add To Viewport
node. Does it print? Which blueprint is this in? -
if it does: is the widget set to be Visible? Can we see the hierarchy?
The same thing happens when I print string as well
It’s in the "GameHUD blueprint
Where would I get the hierarchy?
Adding it wouldn’t change anything. Could you confirm it prints? You should be seeing a blue Hello
in the upper left corner when the game Begins.
It’s in the "GameHUD blueprint
Widgets do not have Begin Play. Is this in a HUD class by any chance?
When you open this blueprint, what do you see in the upper right corner? Parent Class: ???
Where would I get the hierarchy?
In the widget designer, where you designed the widget, added the text block and so on.
No it doesn’t print anything on the screen
The parent class is “HUD”
Is that what you mean with the hierarchy?
Yeah. Looks fine.
The parent class is “HUD”
Got it, makes sense.
No it doesn’t print anything on the screen
Makes sense.
Do you have a Game Mode blueprint? Rings a bell?
I don’t have a game mode blueprint for this level no
Does it mean that you have it for another level where the HUD worked?
Game Mode is tied to a level - so it might be enough to assign a Game Mode to the level.
Essentially: it’s the Game Mode that will create the HUD blueprint. If the level is not using a Game Mode, you can’t create widgets there as the HUD does not exist.
- either create a widget in another blueprint if you do not care for the HUD class
- or have the Game Mode create HUD for you, but the level must be using said Game Mode
Yes I have a gamemode for a level beforehand which is a quiz
I’m confused about how I can get the gamemode now, would I create a gamemode class and then assign the HUD class to the HUD I created?