Compass - need some help

Hi All,

i am attempting to make a compass for our game. Basically want it to post what cardinal direction you are facing depending on your own rotation location.

Can someone please assist in getting me started?

Much appreciated,

hey do you use a Texture or a material?

First thing you would need the Get Control Rotation out of your player controller/Character, break this rotator to the … which was it again… the one around the Y-Axis.

With this you have the rotation when you turn left or right.

If your compass is always visible you would need to Tick the Get Rotation or call an UpdateFunction each time you turn.

Now you would need to translate your rotation to the Texture or Material or whatever you have :slight_smile:

Hi, I also have another solution.

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

For blueprints only; I’d create a compass as a model (visible only to the player, attached to camera) and set it’s local rotation.

Get your control rotation YAW, and find the difference between this and your compass “goal” direction. There’s a node called something like Get Look At Rotation that would help find the “goal” direction. This rotation (yaw) minus your control rotation (yaw) would be the offset. Set the compass models local yaw rotation to this.