Problem when moving socket attached to the weapon

Hello, UE community! Today I tried t0 design ADS system for my FPS project (based on FPS template, not a true fps !!!). So everything works pretty good for me, but I’ve run into one super weird issue, that makes me feel really bad. The point is, that when I move my weapon’s socket forward, Mesh1P actually goes to the right side, whereas when I move my socket to the right sight, Mesh goes forward or backwards. Looks like X and Z axis were reversed.This is the code of my ADS function

void ADarkFantasyCharacter::ADS()
if (Weapon)
FVector p = Weapon->GetSocketLocation(TEXT("RearSight"));
FRotator r;

FVector p1;
FRotator r1;

Mesh1P->TransformToBoneSpace(TEXT("root"), p, r, p1, r1);

FVector f = Mesh1P->GetRelativeLocation() + p1;

FVector RelativeOffset = -f;

Mesh1P->SetRelativeLocation(UKismetMathLibrary::VLerp(Mesh1P->GetRelativeLocation(), Mesh1P->GetRelativeLocation() + RelativeOffset, AimAlpha));
FirstPersonCameraComponent->FieldOfView = FMath::Lerp(FirstPersonCameraComponent->FieldOfView, 60.f, AimAlpha);

GEngine->AddOnScreenDebugMessage(-1, 0.5f, FColor::Red, FString::SanitizeFloat(f.X) + " " + FString::SanitizeFloat(f.Y) + " " + FString::SanitizeFloat(f.Z));

bADS = true;

Some variables are called super stange, because I did it at night (my fault actually).
The main question - How to fix this issue? And how is ADS in traditional FPS game actually designed?

So unreal uses the X axes as the forward axis, and if you don’t import/export your models into unreal with the x axis as forward you will see things like this. You can fix them by creating a blueprint class, and then attaching your model to the scenecomponnent, then rotate your weapon to that is is facing forward (rotate it 90 degrees). Then you place the blueprint in game and now you can rotate the actor and everything works.

The correct way to do it is to import you models correctly. Unreal engine CAN fix imported models, but it’s kinda lame 3 step process that should be a 1 step process.

Step 1) import the model. Model has wong origin point rotation ( x is not forward axis)
Step 2) Export the model OUT OF UNREAL (right click it from content window, export) a dialog box will open. There are a couple options one is to set X axis as forward.
Step 3) Re-import the model that you just exported, make sure X axis is forward in the dialog box. The model should now import facing X axis.