Appearance
播放声音
在.cpp文件中写:
cpp
#include "Kismet/GameplayStatics.h"
void AMyCharacter::OnComponentBeginOverlap(UPrimitiveComponent* OnComponentBeginOverlap, AActor* OtherActor, UPrimitiveComponent* OtherComp, in32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult){
UWorld* World = GetWorld();
UGameplayStatics::PlaySound2D(World, Cast<USoundBase>(StaticLoadObject(USoundBase::StaticClass(), NULL, TEXT("声音资源路径"))));
}