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?