Im trying to add aim deviation to my weapon using a rotator, but as the player looks up the yaw deviation disappears.
Ive checked with some debug strings, and the actual yaw component of the rotator still reads the correct values.
It just doesn’t seem to apply properly?
Got it.
I hijacked FRandomStream::VRandCone(), and customized it.
I didn’t want the spread there because I needed to be able to modify Pitch and Yaw spread separately, and VRandCone was focusing the spread to the center too much when I did that.
// get axes we need to rotate around
FMatrix const DirMat = FRotationMatrix(AimDir.Rotation());
// note the axis translation, since we want the variation to be around X
FVector const DirY = DirMat.GetUnitAxis( EAxis::Z );
FVector const DirZ = DirMat.GetUnitAxis( EAxis::Y );
FVector Result = AimDir.RotateAngleAxis(FMath::FRandRange(-ShotSpread.Y, ShotSpread.Y), DirY);
Result = Result.RotateAngleAxis(FMath::FRandRange(-ShotSpread.Z, ShotSpread.Z), DirZ);
Result = Result.GetSafeNormal();
FinRotator = Result.Rotation();
Gunna leave this here because there weren’t many search results that lead me to FRandomStream::VRandCone() and maybe this will be a different avenue of visibility to someone in the future.