If you want to swap the Line of Sight to use the Camera’s Forward/Position, etc. You can add something like the following to your Submarine actor class:
void ASubmarine::GetCameraView(FVector& outLocation, FRotator& outRotation)
{
if (APlayerController* playerController = Cast<APlayerController>(Controller))
{
if (playerController->PlayerCameraManager)
{
playerController->PlayerCameraManager->GetCameraViewPoint(outLocation, outRotation);
}
}
}
A few notes on that: It only grabs the currently ACTIVE camera’s location and rotation, if your camera is actually a Camera Actor in the world, you could just grab that actor’s location/rotation instead of querying the PlayerCameraManager. Check out this link.