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:
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.
As this is one of the top Google results when searching for this issue with multiplayer, I made a video (posted at the bottom) on a potential solution if this issue is being caused by pawn collision interference. You should double check your spawning logic to make sure your players and pawns aren’t spawning into each other.
tl;dr: One forcible work around is to set the Collision Handling Override to “Try To Adjust Location, But Always Spawn” on your SpawnActor nodes.