Download

Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x0000000000000000

I’m facing the exactly issue below. What’s really odd to me here is that I tried to remove everything but PrimaryActorTick.bCanEverTick = true; from the constructor in EsferaDeFogo.cpp but it still claims there’s error on line 18. Anyways, here’s the script as it is right now. You can ignore the comments I guess.

// Fill out your copyright notice in the Description page of Project Settings.


#include "EsferaDeFogo.h"
#include "Components/SphereComponent.h"


// Sets default values
AEsferaDeFogo::AEsferaDeFogo()
{
 	// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;
	//Cria um instaanciaa e USphereComponent que sera apontada por EsferaDeColisao 
	EsferaDeColisao = CreateDefaultSubobject<USphereComponent>(TEXT("RAIZ"));
	//Define o tamanho do raio a esfera
	EsferaDeColisao->InitSphereRadius(100.f);
	//Define o nome do perfil de colisao
	EsferaDeColisao->SetCollisionProfileName(TEXT("OverlapAllDynamic"));

	//Indica que a EsferaDeColisao sera o componente raiz
	//dad hierarquia de componentes
	RootComponent = EsferaDeColisao;

	//cria uma static mesh component e coloca o endereco
	//de memoria edste recurso no poonteiro EsferaVisivel
	EsferaVisivel = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Esfera"));
	
	/*
	ConstructorHelpers::FObjectFinder<UStaticMesh>Esfera(TEXT("StaticMesh'/Game/StarterContent/Shapes/Shape_Sphere.Shape_Sphere'"));

	if (Esfera.Succeeded())
	{
		EsferaVisivel->SetStaticMesh(Esfera.Object);
		EsferaVisivel->SetRelativeLocation(FVector(0.f, 0.f, -60.f));
	}
	*/

	//Anexa este componente como sendo filho do componente raiz
	//Neste caso EsferaDeColisao
	EsferaVisivel->SetupAttachment(RootComponent);

}

// Called when the game starts or when spawned
void AEsferaDeFogo::BeginPlay()
{
	Super::BeginPlay();
	
}

// Called every frame
void AEsferaDeFogo::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

}


Fatal error!

Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x0000000000000000

0x00007ff9210a28a4 UE4Editor-PrimeiraClasse-3956.dll!AEsferaDeFogo::AEsferaDeFogo() [D:\Documentos\Unreal Projects\PrimeiraClasse\Source\PrimeiraClasse\EsferaDeFogo.cpp:18]
0x00007ff9496bc203 UE4Editor-CoreUObject.dll!UClass::CreateDefaultObject() [D:\Build\++UE4\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\Class.cpp:3707]
0x00007ff94997fabf UE4Editor-CoreUObject.dll!UObjectLoadAllCompiledInDefaultProperties() [D:\Build\++UE4\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectBase.cpp:908]
0x00007ff94996287f UE4Editor-CoreUObject.dll!ProcessNewlyLoadedUObjects() [D:\Build\++UE4\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectBase.cpp:997]
0x00007ff949892305 UE4Editor-CoreUObject.dll!TBaseStaticDelegateInstance<void __cdecl(FName,bool),FDefaultDelegateUserPolicy>::ExecuteIfSafe() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Public\Delegates\DelegateInstancesImpl.h:731]
0x00007ff949fe99ea UE4Editor-Core.dll!TMulticastDelegate<void __cdecl(FName,bool),FDefaultDelegateUserPolicy>::Broadcast() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Public\Delegates\DelegateSignatureImpl.inl:955]
0x00007ff94a0112a8 UE4Editor-Core.dll!FModuleManager::LoadModuleWithFailureReason() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Private\Modules\ModuleManager.cpp:519]
0x00007ff98e24e7d3 UE4Editor-Projects.dll!FModuleDescriptor::LoadModulesForPhase() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Projects\Private\ModuleDescriptor.cpp:561]
0x00007ff98e24eaea UE4Editor-Projects.dll!FProjectManager::LoadModulesForProject() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Projects\Private\ProjectManager.cpp:62]
0x00007ff6b2af53a2 UE4Editor.exe!FEngineLoop::LoadStartupModules() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Launch\Private\LaunchEngineLoop.cpp:3815]
0x00007ff6b2af8a62 UE4Editor.exe!FEngineLoop::PreInitPostStartupScreen() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Launch\Private\LaunchEngineLoop.cpp:3198]
0x00007ff6b2af0eec UE4Editor.exe!GuardedMain() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Launch\Private\Launch.cpp:127]
0x00007ff6b2af125a UE4Editor.exe!GuardedMainWrapper() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:137]
0x00007ff6b2b052bd UE4Editor.exe!WinMain() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:268]
0x00007ff6b2b07fea UE4Editor.exe!__scrt_common_main_seh() [d:\agent\_work\5\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288]
0x00007ff9a9aa7034 KERNEL32.DLL!UnknownFunction []
0x00007ff9abaa2651 ntdll.dll!UnknownFunction []

I don’t know, but shouldn’t you use AttachToComponent instead of SetupAttachment? At least that’s what I’m using… But I’m new to this, so maybe I’m wrong…

Fortunately this is just a little project for studying instead of a big one. For the sake of curiosity I created a new one from scratch and moved the code to it, compiled successfully. I deeply wonder what happened to this one that it feels like the error can’t be solved. I don’t believe that it’s something that eventually happends and only exit is migrating everything, which would be very bad in case of a massive project.