Rotating a vector

Better start working with angles and rotators. Shotgun spread is more easily represented in terms of angles, so you just create a rotator with the yaw and pitch of whatever spread you want. FRotator::RotateVector will transform a vector, so you can just take your camera forward vector and transform it using each shotgun spread rotator.

Also, you’d probably want to randomize shotgun spread, rather than use predefined coordinates. You can use FMath::VRandCone for that. Let’s say you want your maximum shotgun spread to be 2 degrees:


FVector PelletDir = FMath::VRandCone( CameraForwardVector, FMath::DegreesToRadians( 2.0f ) );
GetWorld()->LineTraceSingle( GunHitResult, CameraWorldPosition, CameraWorldPosition + PelletDir * MaxPelletDistance, ECC_Visibility, TraceParams);