Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x0000000000000400

Good day, guys.

I am trying to make a widget using c++ only. I have 2 classes, EnemyStatusClass and EnemyActor. Here are my screenshots.




As you can see in my EnemyStatusClass, I have a public variable, a float variable and a UProgressBar variable. I want to access these variables in the EnemyActor class. When I compile my code, there are no errors, but once I start playing it, it crashes and gives me this message.

Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x0000000000000400

UnrealEditor_Engine
UnrealEditor_Engine
UnrealEditor_Engine
UnrealEditor_Engine
UnrealEditor_Engine
UnrealEditor_UnrealEd
UnrealEditor_UnrealEd
UnrealEditor_UnrealEd
UnrealEditor_UnrealEd
UnrealEditor_UnrealEd
UnrealEditor_UnrealEd
UnrealEditor_UnrealEd
UnrealEditor_UnrealEd
UnrealEditor
UnrealEditor
UnrealEditor
UnrealEditor
UnrealEditor
UnrealEditor
kernel32
ntdll

Run it in the Debugger, and it will tell you where it crashed out at .

I don’t see anywhere that you are setting EnemyName or EnemyHealthBar, is that set in the Blueprints or something?

1 Like

In the last screenshot, line 23, I used the EnemyStatusClass->TryFloat to test things first, even with a normal float variable, the game crashes.

Where are you setting EnemyStatusClass?

1 Like

Sorry. I did not understand your question. What do you mean setting?

Last screen, line 22 shouldn’t work. Functions “Get…Class” return static class. You shoud use

Cast<UEnemyStatusClass>(EnemyStatusWidget);

And always when you use pointers, check them with:

if(EnemyStatusClass)

Add it before UE_LOG and try again.

1 Like

Thank you so much for the help! Will update you once I implemented it on my code.

EnemyStatusClass has to be equal to something, you have to tell the code somewhere what value EnemyStatusClass is.