[Question] Using TextRenderComponent for hud

I’m currently trying to create a small HUD to keep track of four different floats. The problem is that when the camera moves, the text seems to update a bit out of synch with the camera which makes it blurry.

The four separate TextRenderComponents are all parented to the camera in the character blueprint. Do I have to use a separate HUD blueprint?

Also, why is there no float to int? I’m currently doing float → string → int → string.

You should be able to do float–>int using “floor” or “ceil” or “round”. I believe a blueprint will automatically put in a “floor” if you try to connect a float to an int.

I would advise using a separate HUD blueprint, as Luke said as these components are rendered as part of the player character they are subject to the same post process effects as the camera.

You can use the canvas Draw Text function to do this quite smoothly however.

As for float to int, you can use the Round function in Math.Float to round to the nearest int. Unfortunately it doesn’t let you chose between rounding up or down.

Then the next question becomes: how do I even draw the hud? If if try to use tick in my HUD blueprint, I just get a warning “This can only be used during the drawhud event” or something.

If I try to call the Draw hud node from within my character object, the game doesn’t even start. Every time I click the “Play In” button, I get the game exit-sound and a few frames of lag. If I unhook the node, it works but obviously doesn’t draw anything.

Use an Event Receive Draw Hud to drive all your hud draw functions This gives a screen Size int X & Y and ticks every frame.

(this would draw 100, in white, in the centre of the screen. In your case you want 4 draw text functions, one for each timer. Also change the positioning maths to locate the text where you want it. Working absolute values can lead to unexpected results if the resolution changes. It can be good to offset with a % rather than a flat int value, e.g. 5% screen X, 95% screen Y giving lower left), this isn’t a hard rule but it can circumvent future problems.

This needs to take place in the Hud blueprint I.e. a custom blueprint with the parent class “script/Engine.Hud” (selected from the custom classes list on the new BP window), otherwise Event Receive Draw Hud won’t be accessible.

Take a look at the Example projects (blueprint FPS is a good one). There should be a myHud blueprint with a basic set up there as well as some generic stuff about setting up projects correctly, if you’re doing everything else right but still not seeing your hud, it might be your Game Mode HUDClass not being set to your custom Hud, or something similar.

As far as I can tell, there isn’t a single example project that has a blueprint HUD, which is why I’m asking so many questions. I’ve checked the strategy game, shooter game, card game and swing ninja and none of them have it.

I think my problem is more in the calling of the draw hud rather than in the HUD blueprint itself. In my character object I just had Tick → Draw Hud (red circle in the image above), which is what caused the game not to start at all, because that gave me an infinite script warning:

LogScript:Warning: Infinite script recursion (250 calls) detected

Adding a 0.005 delay between Tick and Draw Hud allows me to PIE but I still never manage to get Event Receive Draw HUD to fire.

As you say, it’s likely a problem with my project setup because I have no clue about what should go where. As an example, apart from changing HUD (just now) and Pawn class, I haven’t done anything with Player controller or Game mode.

Thanks for the help, I’ll just keep looking.

Sorry I wasn’t referring to the sample projects, I was referring to the new project defaults. The blueprint FPS definitely has it’s own Hud BP.

You don’t need to call Draw Hud, it will fire every tick automatically; this is what Event Receive Draw Hud.

There is no real documentation about the BP side of canvas, so don’t worry about asking questions. If you’re still having issues I can write up a short tutorial, but it will take a day or so.

Edit: also I have no idea why it keeps reverting the accepted answer status every time I comment, sorry about that

If you’re still having issues there’s a Basic BP HUD tutorial here http://forums.epicgames.com/threads/983333

Thanks, but I’ve pretty much solved the problem. I’d forgotten to set the default game mode in world settings so me editing game mode obviously did nothing.

It’s not pretty but it works:

hud.png

I’m not sure this is the most viable approach, as you’ll get issues like these and your components may be subject to things like post processing. I’d consider handling my HUD in 2d, either using Slate and reskinning it, or from scratch using the canvas.

Could You post your BP HUD tutorial on public forum?
I’m new UE4 owner (not beta) and have no permission to vist: http://forums.epicgames.com/threads/983333. It says “GikaH, you do not have permission to access this page.”

Could you copy/paste that tutorial on: https://forums.unrealengine.com/ ?
Kind regards.