BeginPlay에서 Sound를 설정하는데 궁금하게 있어요

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.

BeginPlay is called at the start of the game or when its spawned

Does that mean every time you shoot a projectile, it makes a sound? Is that why you called on BeginPlay?

Yes.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms