Hello IDK what is wrong but somehow UE 5.4.2 C++ Project Just crashes on compiling.
Here is the code:
GameModeBase (I just set Ap as a default pawn)
G.cpp
#include "G.h"
AG::AG() {
DefaultPawnClass = Ap::StaticClass();
}
G.h
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/GameModeBase.h"
#include "p.h"
#include "G.generated.h"
/**
*
*/
UCLASS()
class MYPROJECT3_API AG : public AGameModeBase
{
GENERATED_BODY()
AG();
};
/// Pawn
p.cpp
// Fill out your copyright notice in the Description page of Project Settings.
#include "p.h"
// Sets default values
Ap::Ap()
{
// Set this pawn to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
cam = CreateDefaultSubobject<UCameraComponent>(TEXT("Cam"));
Mesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Mesh"));
Light = CreateDefaultSubobject<ULightComponent>(TEXT("Light"));
Light->SetupAttachment(cam);
cam->SetupAttachment(Mesh);
}
// Called when the game starts or when spawned
void Ap::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void Ap::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
// Called to bind functionality to input
void Ap::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
}
p.h
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Pawn.h"
#include "Camera/CameraComponent.h"
#include "Components/StaticMeshComponent.h"
#include "Components/LightComponent.h"
#include "p.generated.h"
UCLASS()
class MYPROJECT3_API Ap : public APawn
{
GENERATED_BODY()
public:
// Sets default values for this pawn's properties
Ap();
protected:
UPROPERTY(EditAnywhere)
UCameraComponent* cam;
UPROPERTY(EditAnywhere)
UStaticMeshComponent* Mesh;
UPROPERTY(EditAnywhere)
ULightComponent* Light;
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
// Called to bind functionality to input
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
};
The Unreal engine C++ 5.4.2 just crashes (No warning or Error)
This is the message when it crashes:
Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x00000000000000e8UnrealEditor_Engine!USceneComponent::SetupAttachment() [D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\Components\SceneComponent.cpp:1957]
UnrealEditor_MyProject3!Ap::Ap() [C:\Users\Bohlen4\Documents\Unreal Projects\MyProject3\Source\MyProject3\p.cpp:15]
UnrealEditor_CoreUObject!UClass::CreateDefaultObject() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\Class.cpp:4586]
UnrealEditor_CoreUObject!UClass::InternalCreateDefaultObjectWrapper() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\Class.cpp:5190]
UnrealEditor_CoreUObject!UObjectLoadAllCompiledInDefaultProperties() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectBase.cpp:809]
UnrealEditor_CoreUObject!ProcessNewlyLoadedUObjects() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectBase.cpp:894]
UnrealEditor_CoreUObject!TBaseStaticDelegateInstance<void __cdecl(FName,bool),FDefaultDelegateUserPolicy>::ExecuteIfSafe() [D:\build++UE5\Sync\Engine\Source\Runtime\Core\Public\Delegates\DelegateInstancesImpl.h:777]
UnrealEditor_Core!TMulticastDelegate<void __cdecl(FName,bool),FDefaultDelegateUserPolicy>::Broadcast() [D:\build++UE5\Sync\Engine\Source\Runtime\Core\Public\Delegates\DelegateSignatureImpl.inl:956]
UnrealEditor_Core!FModuleManager::LoadModuleWithFailureReason() [D:\build++UE5\Sync\Engine\Source\Runtime\Core\Private\Modules\ModuleManager.cpp:648]
UnrealEditor_Projects!FModuleDescriptor::LoadModulesForPhase() [D:\build++UE5\Sync\Engine\Source\Runtime\Projects\Private\ModuleDescriptor.cpp:696]
UnrealEditor_Projects!FProjectManager::LoadModulesForProject() [D:\build++UE5\Sync\Engine\Source\Runtime\Projects\Private\ProjectManager.cpp:62]
UnrealEditor!FEngineLoop::LoadStartupModules() [D:\build++UE5\Sync\Engine\Source\Runtime\Launch\Private\LaunchEngineLoop.cpp:4738]
UnrealEditor!FEngineLoop::PreInitPostStartupScreen() [D:\build++UE5\Sync\Engine\Source\Runtime\Launch\Private\LaunchEngineLoop.cpp:4000]
UnrealEditor!GuardedMain() [D:\build++UE5\Sync\Engine\Source\Runtime\Launch\Private\Launch.cpp:136]
UnrealEditor!GuardedMainWrapper() [D:\build++UE5\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:118]
UnrealEditor!LaunchWindowsStartup() [D:\build++UE5\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:258]
UnrealEditor!WinMain() [D:\build++UE5\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:298]
UnrealEditor!__scrt_common_main_seh() [D:\a_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288]
kernel32
ntdll
**
I think the crash is caused by the Attaching components because when I delete it.it works. I am a new to Unreal engine and I don’t know why this happens.
**