UE 5.0 . From time to time Im getting this error when crossing PainCausingVolume and CustomWinVolume. I can
t find out steps after I getting this error, and its not every time, but often. I can
t find any info about it in Internen.
I`ve added checking of pointers everywhere . So this is not a reason
Here the code of WinTrigerVolume
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include “CoreMinimal.h”
#include “Engine/TriggerVolume.h”
#include “WinTriggerVolume.generated.h”
/**
*
*/
UCLASS()
class MOBILEPLATFORMER_API AWinTriggerVolume : public ATriggerVolume
{
GENERATED_BODY()
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// constructor sets default values for this actor's properties
AWinTriggerVolume();
// overlap begin function
UFUNCTION()
void OnOverlapBegin(AActor* OverlappedActor, AActor* OtherActor);
};
// Fill out your copyright notice in the Description page of Project Settings.
#include “WinTriggerVolume.h”
#include “Kismet/GameplayStatics.h”
#include “CustomPlayerController.h”
AWinTriggerVolume::AWinTriggerVolume()
{
OnActorBeginOverlap.AddDynamic(this, &AWinTriggerVolume::OnOverlapBegin);
}
void AWinTriggerVolume::BeginPlay()
{
Super::BeginPlay();
}
//Enable INPUT on overlap
void AWinTriggerVolume::OnOverlapBegin(AActor* OverlappedActor, AActor* OtherActor)
{
APlayerController* FirstLocalPlayer = UGameplayStatics::GetPlayerController(this, 0);
if(FirstLocalPlayer == nullptr) return;
ACustomPlayerController* CustomController = Cast<ACustomPlayerController>(FirstLocalPlayer);
if(CustomController == nullptr) return;
if (OtherActor && (OtherActor != this)) {
if(CustomController != nullptr){
CustomController->WidgetWinner();
}
}
}
The code you provided doesn’t seem to contain any code that could cause a crash, so it’s possible that the issue lies elsewhere in your project. You may want to consider debugging your project to pinpoint the exact location and cause of the crash.
To debug your project, you can use Unreal Engine’s built-in debugging tools, such as the Visual Studio debugger or Unreal’s own debugging tools. You can set breakpoints in your code to pause the execution of your program at certain points and inspect the state of your program.
Additionally, you can use Unreal’s logging system to print out debug information at runtime. You can use the UE_LOG
macro to print out messages to the console or log file, which can help you track down issues in your code.
Overall, it’s great that you’re taking the time to check for null pointers in your code, but keep in mind that there may be other issues in your project that could cause crashes. Debugging your project thoroughly can help you identify and resolve these issues.