This is my first time making a C++ Unreal project. I have been at it for the last few months. I have background in Unity C# as well as basic C++. I’ve been at this for weeks, and it is supposed to be my Senior Overview project, please bear with me.
I am using Unreal 5.0.3
At some point, I was trying to control widgets from my player class. During which I used a line in the header of something like this:
TSubclassOf mywidget;
UUserWidget * mywidgetinstance;
As well as some functions in the cpp file that included creating the widget and adding/removing from viewport. It threw some errors, I research, I add UMG to the .build file. Crashes the editor, editor will not open again. “Oh, last thing I did was add UMG to the build file, i will just undo that at least so the editor opens.” Does not work, I put it back in assuming that yes, I would eventually need the UMG module. More research. Find this answer in this thread. Doesn’t work. I comment out all code relating to the Widgets and re-build. Does not work. More research. At some point I install the debug symbols.
I remove the troublesome player script and rebuild…Unreal opens. Outside the project, I remove the widget code entirely, re add to project. Unreal opens. Okay. Add Widget lines back in. Crash. Remove widget lines, rebuild, crash. Maybe the project just broke. Migrate assets to new project (In attached code, this is why that is the project name, because I used it initially to make sure this wasn’t just a C++ UMG issue, then used it as a backup file). Everything works. Player script without hell UUserwidget code works. UMG being in the build file works. So maybe UUserwidget code will work. Crash. Oh, ok, but If I remove that UUserWidget code that I just added to the script that otherwise worked, it should work, right? No, crash, project won’t open.
Change what I am googling. Find out that maybe I shouldn’t be handling widgets in the player code from this thread. Sure, makes sense in hindsight. Remove Player script. Open engine. Set up according to that thread. All works. Add in player script with uuserwidget stuff commented. Doesn’t work. Wipe all mention of UUserwidget completely. Remove player script. Re Add to Project, rebuild. Okay. Everything works. For now. I do not know what I will do if it decides to turn against me again.
Below is the header and relevant functions after commenting the UUserWidget Stuff. Note that the errors that were given in the crash logs when no mention of UUserWidget exists always refers to around the line where the first mention of UUserWidget was, but otherwise the line works when I re-add it to the project. I know the rest of the code might look kind of ridiculous, but I honestly just want to figure out the issue of the UUserWidget stuff. Everything else works, and I would rather be left to find out the rest of my bad coding habits whilst actually finishing this project.
Header
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "GameFramework/CharacterMovementComponent.h"
#include "Components/SkeletalMeshComponent.h"
#include "Kismet/KismetMathLibrary.h"
#include "Components/SphereComponent.h"
#include "FumbleCharacter.generated.h"
//there is an enum here for movement
UCLASS()
class CATSDODGEBALL_API AFumbleCharacter : public ACharacter
{
GENERATED_BODY ( )
public:
// Sets default values for this character's properties
AFumbleCharacter();
MoveMode movemodeenum { Walking };
UCharacterMovementComponent * charmovement;
USkeletalMeshComponent * charamesh;
//Lots of Bools and floats you would expect from a player controller/
//THESE ARE ALL FOR TERRESTRIAL
//BALL
class USphereComponent * PickupRange;
AActor * ball;
//THESE ARE FOR TRANSITIONS
//this is for making the timers for ui bars work
FTimerHandle bartimerhandle;
bool jIsSuperJumping;
bool jIsChargingSuperJump;
float jSuperJumpHeight;
float jSuperJumpHeld;
//WIDGETS
//------UPROPERTY ( EditAnywhere, Category = "Super Jump" )
//-----------TSubclassOf<UUserWidget> SuperJumpWidget;
//------UUserWidget * SuperJumpWidgetInstance;
//all of my functions are below this. none take a widget-esque argument.
}
cpp file functions
// Sets default values
AFumbleCharacter::AFumbleCharacter()
{
// Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
//------SuperJumpWidgetInstance = CreateWidget<UUserWidget> ( GetWorld ( ), SuperJumpWidget );
charmovement = GetCharacterMovement ( );
PickupRange = this->GetOwner ( )->FindComponentByClass<USphereComponent> ( );
charamesh = this->GetOwner( )->FindComponentByClass<USkeletalMeshComponent> ( );
}
void AFumbleCharacter::jSuperJump ( )
{
if ( movemodeenum == ChargeSuperJump )
{
//...there is code here but it is irrelevant
}
else if ( movemodeenum == Walking )
{
movemodeenum = ChargeSuperJump;
jIsChargingSuperJump = true;
tIsWalking = false;
tCanWalk = false;
//Make Bar Widget
//-------SuperJumpWidgetInstance->AddToViewport ( );
//Start Timer
GetWorld ( )->GetTimerManager ( ).SetTimer( bartimerhandle, jSuperJumpDelegate, 0.03f, true, 0.f );
}
}
void AFumbleCharacter::jSuperJumpUIClose ( ) // this is called by timer to remove widget shortly after action is complete but not immediately
{
//-------SuperJumpWidgetInstance->RemoveFromViewport( );
}
These are the errors it gives me in the crash handler when there is no more UUserWidget in my player script.
Callstack
[2023.04.06-14.25.52:227][ 0]LogWindows: Error: === Critical error: ===
[2023.04.06-14.25.52:227][ 0]LogWindows: Error:
[2023.04.06-14.25.52:227][ 0]LogWindows: Error: Fatal error!
[2023.04.06-14.25.52:227][ 0]LogWindows: Error:
[2023.04.06-14.25.52:227][ 0]LogWindows: Error: Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x0000000000000000
[2023.04.06-14.25.52:227][ 0]LogWindows: Error:
[2023.04.06-14.25.52:227][ 0]LogWindows: Error: [Callstack] 0x00007ff8e3943d44 UnrealEditor-TestingCproject.dll!AFumbleCharacter::AFumbleCharacter() [P:\Game Projects\TestingCproject\Source\TestingCproject\FumbleCharacter.cpp:12]
[2023.04.06-14.25.52:227][ 0]LogWindows: Error: [Callstack] 0x00007ff95a3ec44d UnrealEditor-CoreUObject.dll!UClass::CreateDefaultObject() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\Class.cpp:3897]
[2023.04.06-14.25.52:227][ 0]LogWindows: Error: [Callstack] 0x00007ff95a6c04dd UnrealEditor-CoreUObject.dll!UObjectLoadAllCompiledInDefaultProperties() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectBase.cpp:836]
[2023.04.06-14.25.52:227][ 0]LogWindows: Error: [Callstack] 0x00007ff95a6a030b UnrealEditor-CoreUObject.dll!ProcessNewlyLoadedUObjects() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectBase.cpp:920]
[2023.04.06-14.25.52:227][ 0]LogWindows: Error: [Callstack] 0x00007ff95a5582a5 UnrealEditor-CoreUObject.dll!TBaseStaticDelegateInstance<void __cdecl(FName,bool),FDefaultDelegateUserPolicy>::ExecuteIfSafe() [D:\build++UE5\Sync\Engine\Source\Runtime\Core\Public\Delegates\DelegateInstancesImpl.h:731]
[2023.04.06-14.25.52:227][ 0]LogWindows: Error: [Callstack] 0x00007ff956d1a5c2 UnrealEditor-Core.dll!TMulticastDelegate<void __cdecl(FName,bool),FDefaultDelegateUserPolicy>::Broadcast() [D:\build++UE5\Sync\Engine\Source\Runtime\Core\Public\Delegates\DelegateSignatureImpl.inl:967]
[2023.04.06-14.25.52:227][ 0]LogWindows: Error: [Callstack] 0x00007ff956d3e937 UnrealEditor-Core.dll!FModuleManager::LoadModuleWithFailureReason() [D:\build++UE5\Sync\Engine\Source\Runtime\Core\Private\Modules\ModuleManager.cpp:558]
[2023.04.06-14.25.52:227][ 0]LogWindows: Error: [Callstack] 0x00007ff968adaaf6 UnrealEditor-Projects.dll!FModuleDescriptor::LoadModulesForPhase() [D:\build++UE5\Sync\Engine\Source\Runtime\Projects\Private\ModuleDescriptor.cpp:690]
[2023.04.06-14.25.52:227][ 0]LogWindows: Error: [Callstack] 0x00007ff968adae31 UnrealEditor-Projects.dll!FProjectManager::LoadModulesForProject() [D:\build++UE5\Sync\Engine\Source\Runtime\Projects\Private\ProjectManager.cpp:62]
[2023.04.06-14.25.52:227][ 0]LogWindows: Error: [Callstack] 0x00007ff618f053cb UnrealEditor.exe!FEngineLoop::LoadStartupModules() [D:\build++UE5\Sync\Engine\Source\Runtime\Launch\Private\LaunchEngineLoop.cpp:4118]
[2023.04.06-14.25.52:227][ 0]LogWindows: Error: [Callstack] 0x00007ff618f0866e UnrealEditor.exe!FEngineLoop::PreInitPostStartupScreen() [D:\build++UE5\Sync\Engine\Source\Runtime\Launch\Private\LaunchEngineLoop.cpp:3469]
[2023.04.06-14.25.52:227][ 0]LogWindows: Error: [Callstack] 0x00007ff618f00bbd UnrealEditor.exe!GuardedMain() [D:\build++UE5\Sync\Engine\Source\Runtime\Launch\Private\Launch.cpp:137]
[2023.04.06-14.25.52:227][ 0]LogWindows: Error: [Callstack] 0x00007ff618f00e8a UnrealEditor.exe!GuardedMainWrapper() [D:\build++UE5\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:147]
[2023.04.06-14.25.52:227][ 0]LogWindows: Error: [Callstack] 0x00007ff618f03c4d UnrealEditor.exe!LaunchWindowsStartup() [D:\build++UE5\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:283]
[2023.04.06-14.25.52:227][ 0]LogWindows: Error: [Callstack] 0x00007ff618f15564 UnrealEditor.exe!WinMain() [D:\build++UE5\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:330]
[2023.04.06-14.25.52:227][ 0]LogWindows: Error: [Callstack] 0x00007ff618f18736 UnrealEditor.exe!__scrt_common_main_seh() [d:\a01_work\6\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288]
[2023.04.06-14.25.52:228][ 0]LogWindows: Error: [Callstack] 0x00007ff97bec7614 KERNEL32.DLL!UnknownFunction []
[2023.04.06-14.25.52:228][ 0]LogWindows: Error: [Callstack] 0x00007ff97dac26a1 ntdll.dll!UnknownFunction []
[2023.04.06-14.25.52:228][ 0]LogWindows: Error:
[2023.04.06-14.25.52:307][ 0]LogExit: Executing StaticShutdownAfterError
[2023.04.06-14.25.52:308][ 0]LogWindows: FPlatformMisc::RequestExit(1)
[2023.04.06-14.25.52:308][ 0]LogWindows: FPlatformMisc::RequestExitWithStatus(1, 3)
[2023.04.06-14.25.52:308][ 0]LogCore: Engine exit requested (reason: Win RequestExit)
[2023.04.06-14.25.52:352][ 0]Log file closed, 04/06/23 09:25:52
I know this is a lot of text, but I really am at a loss. I really want to know if I should just fail my class and retake it again doing something that will actually work. Any help is immensely appreciated.
These are my questions and general lack of understandings:
Why did this happen in the first place? I want to know so that I avoid something like this ever happening again, and I’m kind of terrified of it happening again with this project. It’s really soiling my Unreal experience. I normally really enjoy debugging, but this pushed me too far.
Why would Unreal compile code that would break it this badly?
Why does Unreal still crash at the line where the first problem lines of code was if it has been rebuilt without those lines of code? Does Unreal somehow flag that in a way that the only way to clear the tag is to remove the script, rebuild, add the script, rebuild?