FVector ASWeapon::GetCameraDamageStartLocation(const FVector& AimDir) const { ASPlayerController* PC = MyPawn ? Cast<ASPlayerController>(MyPawn->Controller) : nullptr; FVector OutStartTrace = FVector::ZeroVector; if (PC) { FRotator DummyRot; PC->GetPlayerViewPoint(OutStartTrace, DummyRot); // Adjust trace so there is nothing blocking the ray between the camera and the pawn, and calculate distance from adjusted start OutStartTrace = OutStartTrace + AimDir * (FVector::DotProduct((Instigator->GetActorLocation() - OutStartTrace), AimDir)); } return OutStartTrace; }
FVector ASWeapon::GetCameraDamageStartLocation(const FVector& AimDir) const { ASPlayerController* PC = MyPawn ? Cast<ASPlayerController>(MyPawn->Controller) : nullptr; FVector OutStartTrace = FVector::ZeroVector; if (PC) { FRotator dummyRot; PC->GetPlayerViewPoint(OutStartTrace, dummyRot); // Adjust trace so there is nothing blocking the ray between the camera and the pawn, and calculate distance from adjusted start // TODO: Break down into easy to understand code (copied from ShooterGame) OutStartTrace = OutStartTrace + AimDir * ((Instigator->GetActorLocation() - OutStartTrace) | AimDir); } return OutStartTrace; }