UnrealScripterAI
Discord ↗
Link Copied to Clipboard
×
"create a dog"
ADog::ADog() { PrimaryActorTick.bCanEverTick = true; // Create the dog mesh DogMesh = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("Dog Mesh")); DogMesh->SetupAttachment(RootComponent); // Create the dog's audio component DogAudio = CreateDefaultSubobject<UAudioComponent>(TEXT("Dog Audio")); DogAudio->SetupAttachment(RootComponent); } void ADog::Tick(float DeltaTime) { Super::Tick(DeltaTime); // If the dog is barking, play the barking sound if (bIsBarking) { DogAudio->SetSound(BarkingSound); DogAudio->Play(); } else { DogAudio->Stop(); } }