Well, I finally figured it out. I wish someone would have told me that more needs to be done with DeprojectMousePositionToWorld to get a usable mouse location as that was basically the main offender problem.
In any case, for anyone who’s looking to get a similar effect in their game, here’s what I do to fire a projectile at the mouse location from a held weapon in the character’s hand:
//get the current mouse and equipment location
FVector EquipmentLocationLocal = GetActorLocation();
FVector MouseLocationLocal;
FHitResult HitResult;
GetWorld()->GetFirstPlayerController()->GetHitResultUnderCursor(ECC_Visibility, false, HitResult);
if (HitResult.bBlockingHit)
{
MouseLocationLocal = HitResult.ImpactPoint;
}
//calculate the angle of the vector from the equipment to mouse, ignoring the X value
FVector NewVectorLocal = MouseLocationLocal - EquipmentLocationLocal;
NewVectorLocal.X = 0;
FRotator SpawnRotationLocal = FRotationMatrix::MakeFromX(NewVectorLocal).Rotator();
SpawnRotationLocal.Pitch, SpawnRotationLocal.Yaw, SpawnRotationLocal.Roll));
AEquipmentProjectile* ProjectileLocal = GetWorld()->SpawnActor<AEquipmentProjectile>(AEquipmentProjectile::StaticClass(), EquipmentLocationLocal, SpawnRotationLocal);
I’m sure it’s not pretty, so anyone can feel free to correct anything about it, but all the components needed are there. The essential parts was using GetHitResultUnderCursor for the mouse location in world.