Blueprint Runtime Error: Accessed None trying to read value of variable

Basically when I attack an enemy I want to get the “isBoss” variable using the hit actor but I get this error(Btw this is my first project so I don’t really know what I 'm doing)


1 Like

The variable is not assigned, that’s usually the problem.

But, a bool is always assigned, so, that must mean your ‘cast to class’ node is not working.

So, either you have not traced to anything, or it is not of that class.

Hey @Manabys! Welcome to the forums!

So you shouldn’t need a “Get Actor of Class” here because that’s a search function, you already have your target because of the line trace. Instead you can do a “Class ==” instead of a cast, then that will return a Bool you can use with a branch. If it is == BP_Enemy, do this. Put your cast stuff after that. :slight_smile:

Hope that helps!

3 Likes

Another option if you don’t need any other class variables/functions etc is to add a Actor Tag and check if it exists.

Going more complex you can use GamePlay Tags with a C++ implementation to gain access to the GamePlayTagsAssetInterface.

1 Like

Thank you I solved it

That’s great! Can you let us know what you did to solve it for future answer seekers?

Thanks!

1 Like