Blueprint Runtime Error: "Accessed None trying to read property CallFunc_GetActorOfClass_ReturnValue", Node:"

I’ve been trying to make a game based on the first-person shooter tutorial. I’ve created a menu screen and made multiple levels. However, I need a counter to see when all the enemies have been killed, (if it helps, all of the enemies have the tag AI) so I created a variable called KilledEnemies and every time an enemy deletes, then it would add 1 to the counter, and when it hits 7 (total enemies in the easy level), and then it does nothing (i haven’t got there yet). But I keep getting this error:



(under BP_FirstPersonProjectile, the below blueprint)

(under EasyLevelDatabase, the below blueprint)

If you need anything else let me know,( and the variable is not hidden)

GetActorOfClass will return NULL when there are no actors of that class in the level.

Trying to access properties or call functions of a NULL pin will always log this kind of errors.

You can check the object is not null with an “Is Valid” check node.

Make sure you either added the EasyLevelDatabase actor in the level (just drag&drop in the map), or spawn it dynamically (from eg. gamemode class) with SpawnActor.

7 Likes

Thanks I was having the same problem and that fixed it.