Unreal Engine Crash when stepping into Trigger Volume

Unreal crashes when I step into the trigger volume to open the doors in this lecture.

I tested it and it only happens when the engine tries to run the code Play(); with sounds. So I guess it must be something with the audio engine.

This is the error that it gives when it crashes:

LoginId:9a81ca81844513ea857d1d9327e519fb

EpicAccountId:04bf92fa94fd44dcbe1fcdfa6e123ad6

Caught signal

UOpenDoor::TickComponent(float, ELevelTick, FActorComponentTickFunction*) Address = 0x183f1af74 [/Volumes/LG SSD 01/C++ Course/Building Escape/BuildingEscape/Source/BuildingEscape/OpenDoor.cpp, line 55] [in UE4Editor-BuildingEscape-5926.dylib]

FActorComponentTickFunction::ExecuteTick(float, ELevelTick, ENamedThreads::Type, TRefCountPtr const&) Address = 0x104bdc73c (filename not found) [in UE4Editor-Engine.dylib]

FTickFunctionTask::DoTask(ENamedThreads::Type, TRefCountPtr const&) Address = 0x105a2d820 (filename not found) [in UE4Editor-Engine.dylib]

TGraphTask::ExecuteTask(TArray<FBaseGraphTask*, FDefaultAllocator>&, ENamedThreads::Type) Address = 0x105a2d133 (filename not found) [in UE4Editor-Engine.dylib]

FNamedTaskThread::ProcessTasksNamedThread(int, bool) Address = 0x101a6ef7c (filename not found) [in UE4Editor-Core.dylib]

FNamedTaskThread::ProcessTasksUntilIdle(int) Address = 0x101a6e1a4 (filename not found) [in UE4Editor-Core.dylib]

FTickTaskSequencer::ReleaseTickGroup(ETickingGroup, bool) Address = 0x105a26cfa (filename not found) [in UE4Editor-Engine.dylib]

FTickTaskManager::RunTickGroup(ETickingGroup, bool) Address = 0x105a20918 (filename not found) [in UE4Editor-Engine.dylib]

UWorld::Tick(ELevelTick, float) Address = 0x105100f2b (filename not found) [in UE4Editor-Engine.dylib]

UEditorEngine::Tick(float, bool) Address = 0x10a8a86e7 (filename not found) [in UE4Editor-UnrealEd.dylib]

UUnrealEdEngine::Tick(float, bool) Address = 0x10b29f298 (filename not found) [in UE4Editor-UnrealEd.dylib]

FEngineLoop::Tick() Address = 0x101971d54 (filename not found) [in UE4Editor]

GuardedMain(wchar_t const*) Address = 0x10197bb48 (filename not found) [in UE4Editor]

-[UE4AppDelegate runGameThread:] Address = 0x101985c8e (filename not found) [in UE4Editor]

-[FCocoaGameThread main] Address = 0x101be7801 (filename not found) [in UE4Editor-Core.dylib]

Unknown() Address = 0x7fff31927882 (filename not found) [in Foundation]

_pthread_start Address = 0x7fff693e8109 (filename not found) [in libsystem_pthread.dylib]

thread_start Address = 0x7fff693e3b8b (filename not found) [in libsystem_pthread.dylib]

Need some help here.

Hardware:

Model Name: MacBook Pro
Model Identifier: MacBookPro11,2
Processor Name: Quad-Core Intel Core i7
Processor Speed: 2.2 GHz
Number of Processors: 1
Total Number of Cores: 4
L2 Cache (per Core): 256 KB
L3 Cache: 6 MB
Hyper-Threading Technology: Enabled
Memory: 16 GB
Boot ROM Version: 159.0.0.0.0
SMC Version (system): 2.18f15
Serial Number (system): C02P866FG3QC
Hardware UUID: 36D9A928-709C-54BC-A7AD-2E5591F7BD8F

System Software:

System Version: macOS 10.15.4 (19E287)
Kernel Version: Darwin 19.4.0
Boot Volume: Macintosh HD
Boot Mode: Normal
Computer Name: Luichy’s MacBook Pro
User Name: Luis Guzman (LGuzman)
Secure Virtual Memory: Enabled
System Integrity Protection: Enabled
Time since boot: 4:30

UPDATE 1:

I went and applied all Lecture Project Changes and now it doesn’t crash but not playing sound.

This is my .cpp code for audio triggering (I have all my includes):

  1. void UOpenDoor::BeginPlay()
  • void UOpenDoor::FindAudioComponent()
  1. {
  2. AudioComponent = GetOwner()->FindComponentByClass();
  • if (!AudioComponent)
  1. {
  2. UE_LOG(LogTemp, Error, TEXT(“There is no audio component present on %s!”), *GetOwner()->GetName());
  3. }
  4. }
  • void UOpenDoor::OpenDoor(float DeltaTime)
  1. {
  2. CloseDoorSound = false;
  3. if (!AudioComponent) {return;}
  4. if (!OpenDoorSound)
  5. {
  6. AudioComponent->Play();
  7. OpenDoorSound = true;
  8. }
  9. }
  • void UOpenDoor::CloseDoor(float DeltaTime)
  1. {
  2. OpenDoorSound = false;
  3. if (!AudioComponent) {return;}
  4. if (!CloseDoorSound)
  5. {
  6. AudioComponent->Play();
  7. OpenDoorSound = true;
  8. }
  9. }

UPDATE 2:

Solved! Some lines of code were missing.

Can you please post your code?

Sure! Here it is:

#include "OpenDoor.h"
#include "Components/AudioComponent.h"
#include "Components/PrimitiveComponent.h"
#include "Engine/World.h"
#include "GameFramework/PlayerController.h"
#include "GameFramework/Actor.h"

#define OUT

// Sets default values for this component's properties
UOpenDoor::UOpenDoor()
{
	// Set this component to be initialized when the game starts, and to be ticked every frame.  You can turn these features
	// off to improve performance if you don't need them.
	PrimaryComponentTick.bCanEverTick = true;

	// ...
}

// Called when the game starts
void UOpenDoor::BeginPlay()
{
	Super::BeginPlay();

	InitialYaw = GetOwner()->GetActorRotation().Yaw;
	CurrentYaw = InitialYaw;
	// OpenAngle = InitialYaw + OpenAngle;
	OpenAngle += InitialYaw;

	FindPressurePlate(); 
	FindAudioComponent();
	{
		UE_LOG(LogTemp, Error, TEXT("%s has the OpenDoor component on it, but no PressurePlate set!"), *GetOwner()->GetName());
	}
}

void UOpenDoor::FindAudioComponent()
{
	AudioComponent = GetOwner()->FindComponentByClass<UAudioComponent>();

	if (!AudioComponent)
	{
		UE_LOG(LogTemp, Error, TEXT("%s has the open door component on it, but no pressureplate set!"), *GetOwner()->GetName());	
		UE_LOG(LogTemp, Error, TEXT("%s Missing audio component!"), *GetOwner()->GetName());
	}
}

void UOpenDoor::FindPressurePlate()
{
	if(!PressurePlate)
		{
			UE_LOG(LogTemp, Error, TEXT("%s has the open door component on it, but no pressureplate set!"), *GetOwner()->GetName());	
		}
}

// Called every frame
void UOpenDoor::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
	Super::TickComponent(DeltaTime, TickType, ThisTickFunction);

	if (TotalMassOfActors() > MassToOpenDoors)
	{
		OpenDoor(DeltaTime);
		DoorLastOpened = GetWorld()->GetTimeSeconds();
	}
	else
	{
		if(GetWorld()->GetTimeSeconds() - DoorLastOpened > DoorCloseDelay)
		{
			CloseDoor(DeltaTime);
		}
	}
}

void UOpenDoor::OpenDoor(float DeltaTime)
{
	CurrentYaw = FMath::FInterpTo(CurrentYaw, OpenAngle, DeltaTime, DoorOpenSpeed);
	FRotator DoorRotation = GetOwner()->GetActorRotation();
	DoorRotation.Yaw = CurrentYaw;
	GetOwner()->SetActorRotation(DoorRotation);

	CloseDoorSound = false;
	if (!AudioComponent) {return;}
	if (!OpenDoorSound)
	{
		AudioComponent->Play();
		OpenDoorSound = true;
	}
}

void UOpenDoor::CloseDoor(float DeltaTime)
{
	CurrentYaw = FMath::FInterpConstantTo(CurrentYaw, InitialYaw, DeltaTime, DoorCloseSpeed);
	FRotator DoorRotation = GetOwner()->GetActorRotation();
	DoorRotation.Yaw = CurrentYaw;
	GetOwner()->SetActorRotation(DoorRotation);

	OpenDoorSound = false;
	if (!AudioComponent) {return;}
	if (!CloseDoorSound)
	{
		AudioComponent->Play();
		CloseDoorSound = true;
	}
}

float UOpenDoor::TotalMassOfActors() const
{
	float TotalMass = 0.f;

	// Find All Overlapping Actors.
	TArray<AActor*> OverlappingActors;
	if (!PressurePlate) {return TotalMass;}
	PressurePlate->GetOverlappingActors(OverlappingActors);
	
	// Add Up Their Masses.
	
	for(AActor* Actor : OverlappingActors)
	{
		TotalMass += Actor->FindComponentByClass<UPrimitiveComponent>()->GetMass();
	}
	return TotalMass;
}

In BeginPlay() you have the UE_LOG statement in braces. And in FindAudioComponent() you have the UE_LOG statement of “No PressurePlate Set.” Otherwise I find nothing wrong with your code.

So I think that the problem has been resolved and the game is working as expected?

Everything Ok.

Privacy & Terms