Projectile spawning in weird angle

It is spawning in direction of 45 degrees to the left.
Why is that?

void AGunBase::Shoot()
UGameplayStatics::SpawnEmitterAttached(MuzzleFlash, Mesh, TEXT("Muzzle"));
UGameplayStatics::SpawnSoundAttached(MuzzleSound, Mesh, TEXT("Muzzle"));

FRotator SpawnRotation;
FVector SpawnLocation;
GetOwnerController()->GetPlayerViewPoint(SpawnLocation, SpawnRotation);
if (ProjectileClass != nullptr)
UWorld* const World = GetWorld();
if (World != nullptr)
ABullet* Bullet = World->SpawnActor<ABullet>(ProjectileClass, SpawnLocation,SpawnRotation);

FVector NewVelocity = GetActorForwardVector() * Bullet->BulletSpeed;
Bullet->Velocity = NewVelocity;


Thanks for help.

I just took wrong Vector. Instead of GetActorForwardVector(), I should use GetActorUpVector()

1 Like