void AProjectile::BeginPlay()
{
Super::BeginPlay();
ProjectileMesh->OnComponentHit.AddDynamic(this, &AProjectile::OnHit);
if (LaunchSound)
{
UGameplayStatics::PlaySoundAtLocation(this, LaunchSound, GetActorLocation());
}
}
LaunchSound is the sound of shooting a projectile, but I don’t know why BeginPlay writes UGameplayStatics::PlaySoundAtLocation(this, LaunchSound, GetActorLocation());
code.
I’ve heard that BeginPlay runs only once the game starts. But Launch Sound has to make a sound every time you shoot a projectile, so I don’t know why it’s done with Begin Play.