[Need help] Problem with Camera direction

Hello Devs,

I’m currently able to make a trace from the character’s eyes (-5 units under) to his crosshair using the following :

FVector AimStartingPoint = GetActorLocation() + CameraRelativePosition;
FVector AimEndingPoint = FirstPersonCameraComponent->GetComponentRotation().Vector() * ScanDistance;
DrawDebugLine(GetWorld(), AimStartingPoint + FVector(0, 0, -5), AimEndingPoint, FColor(255, 255, 255));

The problem is that the trace is never going directly to the center of the screen but instead it goes a bit around it.

I don’t know if I’m in the right way or is there another solution to get the camera direction?

Cheers!

Still looking for some advice

If you’re using a traditional first person view, then you need to add the eye offset to the position of the actor.
I don’t know the value of CameraRelativePosition, so I don’t know if you’ve already done this.

You should just be able to use GetActorEyesViewPoint():


FVector AimStart;
FRotator AimRotation;

GetActorEyesViewPoint(AimStart, AimRotation);

AimStart += FVector(0, 0, -5);

FVector AimEnd = AimStart + AimRotation.Vector() * ScanDistance;

DrawDebugLine(GetWorld(), AimStart, AimEnd, FColor::White);

Tyvm, works perfectly!