This is my first ever tutorial so let me know what you think. In the tutorial I cover how to make a custom function for an in game compass using blueprints and how to create a UMG HUD element in the top right corner which will update when you turn your camera.
I spent most of last night trying to figure out what way was actually North LOL. Looking down on your map from a Top Orthographic view though it is pretty obvious that Y-Axis is North-South. Another confusing part about in game Yaw is that it’s backwards.
Yaw is supposed to go Counter-clockwise, starting with 0 being East, 90 Degrees North. In-game though, Yaw is going clockwise making 90 degrees south.
**CREDIT GOES TO Vanlacke, as it is his answer to this question below which got me on the idea for this tutorial **
Took me a few hours, but it is a UMG Material, with a pan parameter, and then a simple Rotator.yaw calculation.
I use MinMaxNormalize which is exactly the same as NormalizeToRange, but I didn’t include the Kismet math header at the time so… there’s that.
The texture is X seamless, and North is in the middle. If South was in the middle, just simply add 0.5 to each result below.
I use a material, that exposes a float3 parameter, but I only change the ‘R’ or ‘X’ value, between -1 and 1, depending on the heading.
I then calculate the -1 to 1 value using this code:
Then in UMG I created a dynamic material instance, and set my HUD Brush to that, and then applied this Blueprint code in the UMG tick event.
It simply sets the Material Pan ‘R’ parameter value, which is only really offsetting the U of the texture coordinate.
And here is a compass blueprint in the world so I could test my compass. Visible in the top