How can i get the angle of the cube's face i'm looking at?

Hello, i have a cube and i would like to know the angle between my forward vector and the cube’s face forward vector that i’m currently looking at. I have the following working logic:

FVector Normal = Cube->GetTransform().InverseTransformVectorNoScale(HitResult.Normal);

FVector Vector;
FString Side;

if (Normal.Equals(FVector(1.0f, 0.0f, 0.0f)))
{
	Side = "Front";
	Vector = Cube->GetActorForwardVector();
}
else if (Normal.Equals(FVector(0.0f, 1.0f, 0.0f)))
{
	Side = "Right";
	Vector = Cube->GetActorRightVector();
}                
else if (Normal.Equals(FVector(-1.0f, 0.0f, 0.0f)))
{
	Side = "Back";
	Vector = -Cube->GetActorForwardVector();
}                
else if (Normal.Equals(FVector(0.0f, -1.0f, 0.0f)))
{
	Side = "Left";
	Vector = -Cube->GetActorRightVector();
}                

FVector Value = GetTransform().InverseTransformVectorNoScale(Vector);

float Angle = FMath::RadiansToDegrees(FMath::Atan2(Value.X, Value.Y));

This gives-me -90º when i’m looking directly to the face and it works, but i’m sure there has to be a better way to do this ! Thank you.

A trace will return the normal angle, but I am not sure what context you are needing this info in so I don’t know how useful that will. be.

I am already using a trace to get the normal:

FVector Normal = Cube->GetTransform().InverseTransformVectorNoScale(HitResult.Normal);

Notice the HitResult.Normal. I’m using this to know when i’m looking directly into a cube’s face so i know i can play a vault over / wall climb animation, otherwise he would play the animation in the wrong direction.

I really overcomplicated this, after spending some time i ended up with:

FVector Normal = GetTransform().InverseTransformVectorNoScale(HitResult.Normal);

float Angle = FMath::RadiansToDegrees(FMath::Atan2(Normal.X, Normal.Y));

The first step wasn’t necessary at all :stuck_out_tongue: