Hey guys so this is my code. Basically I’m just trying to fire a projectile so it goes to the center of the screen. As far as I can tell this should be working because it Compiles just fine and everything, but when I go to fire my weapon the ball only fires in one direction and I logged out the Rotation, and the Rotation never changes. It doesn’t matter what direction I’m facing or if the LineTrace hits anything or not. Any ideas would be greatly appreciated.
#include “Kismet/KismetMathLibrary.h”
Void AActor:OnFire();
{
Float Distance = 10000.0f;
FHitResult Hit;
FVector Start = FirstPersonCameraComponent->GetComponentLocation();
FVector End = Start + (FirstPersonCameraComponent->GetForwardVector()* Distance);
FRotator SpawnRotation = UKismetMathLibrary::FindLookatRotation(FP_MuzzleLocation->GetComponentLocation(), Hit.TraceEnd);
FVector SpawnLocation = FP_MuzzleLocation ->GetComponentLocation() + SpawnRotation.RotateVector(GunOffset);
GetWorld()->LineTraceSingleByChannel(Hit,Start,End,ECC_Visibility);
If(Hit.bBlockingHit)
{
FActorSpawnParameters ActorSpawnParams;
ActorSpawnParams.SpawnCollisionHandlingOveride = ESpawnActorCollisionHandlingMethod::AdjustIfPossibleButDontSpawnIfColliding;
World->SpawnActor<AFirstPersonProjectile>(ProjectileClass, SpawnLocation, SpawnRotation, ActorSpawnParams);
}