Display heading in HUD

Hello;

I am trying to make a HUD that displays the current first person heading within the environment. I have the static elements of the HUD laid out and a variable (int) called “heading”, however I have not been able to find out how to update the variable with the users heading.

Can someone please point me in the direction of a suitable guide/implementation that would allow a live heading to be displayed on the HUD?

EDIT:

With the help of Allar below I am nearly there -

I have a GetRotationXVector returning the X Value to a variable Heading. This is then returned and added to my HUD. My Question is;

How do I update the value / HUD when the user moves around?

Thanks;

Andy

You can get the player character’s world rotation and treat the Yaw as its heading.

You can then use UMG or some HUD DrawText to draw the heading to the screen.

Thanks. How do I cast the just the Yaw of the rotation to an INT? (I cant find a way to update the yaw value in my UMG HUD).

Just drag the float to an int pin and it’ll auto convert it. Or you can Truncate or Floor it. You should be able to set the text of a text widget though by going from float to FText or String.

Can you help me with the edit I posted above? I dont seem to be getting an updated heading as I move around the game. Thanks

Hi, geekyhawkes,

  1. get actor rotation, the yaw value from rotation is actually the heading value you want.
  2. you can bind the yaw value to your umg control or Draw heading flag in HUD::DrawHUD function.
  3. on players Tick event to update the yaw value, and umg control or HUD will auto update

steps:

  1. add a float variable called heading in character bp class.
  2. add Tick event in character eventgraph, and get actor rotation >> break rotator >> set z value to heading variable.
  3. create a umg user widget, add a text(TextBlock in older version), create bind on text property in content category. get player actor >> cast to projectcharacter type >> set heading value to return value.

if you want to do more custom display than a text show heading number value eg. compass, just do it, you get the heading value in widget now.

cheers.
omega
.

Just assign the text in a Tick event or your Draw HUD event or assign it to a variable on Tick and then bind your UMG widget to that variable.

Thank you so much! I am struggling with the stage connecting Event Tick - >>Get actor Rotation (the engine wont let me connect these 2). My Event Tick lists My Geometry and In Delta time - Get actor rotation lists only Target (self) and its return value.

get actor rotation return a rotator, you need use break rotator to break to roll, yaw, pitch. and just use yaw value as your heading value.

and remember add this in your character blueprint class. then get actor rotation means get your player’s rotation, not other actor’s rotation.

good luck!

ok - ready for a stupid question from me? I am using the Unreal Basic template from the editor (the one that just loads the chairs and desk) and cannot find the third person character /blueprint component. I am guessing there must be some sort of pawn etc added somewhere as I can walk and fly around my level. (thanks for your help so far)

OH~man, are you kidding me?
Basic template is a empty template with nothing, If you want to build a third person game or most time in third person game, start from a third person template is a wise idea.

Cheers!
Omega