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?
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.
get actor rotation, the yaw value from rotation is actually the heading value you want.
you can bind the yaw value to your umg control or Draw heading flag in HUD::DrawHUD function.
on players Tick event to update the yaw value, and umg control or HUD will auto update
steps:
add a float variable called heading in character bp class.
add Tick event in character eventgraph, and get actor rotation >> break rotator >> set z value to heading variable.
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.
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.
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.