Download

How to fix "Accesed 'None' whilst trying to read SpawnActorfromClass"?

I’d like to spawn into my game as a randomly selected character but I can’t seem to get it to work without some sort of error popping up and it’s driving me nuts. I’ve tried storing all my child character blueprints into an array and then getting a random integer and possessing whichever character is selected using SpawnActorfromClass which works just fine, for the most part. The problem is, although I don’t get any compiling errors, when I exit the game, I get a bunch of errors telling me that the blueprint accessed “None” whilst trying to read the SpawnActorfromClass node. Not only that but it won’t spawn me at any of the Player Start points that I’ve set up AND spawns me into the game as a clone of my BaseCharacter, so there’s two characters in the scene. Any idea on how to fix this? Thanks!

Edit: fixed the “Accessed ‘None’ whilst trying to read SpawnActorfromClass” issue by storing the locations of my Player Starts into an array and plugging that into the transform pin (definitely not the best solution but it’ll do for now, I guess). However, I’ve encountered another issue where, after starting the game 4 or 5 times, my cloned self and my weapon variables are no longer being spawned/set

I often forget to check my pointers in blueprint. So I end up with a LOT of these errors when ending play. To fix it, I use the ‘isvalid’ macro. Not the pure node that returns a boolean, but the macro with two output pins. This will check the reference to make sure it’s actually in the world and ready.

When it comes to your second issue, is this occurring in standalone as well as PIE?

I fixed the first issue!!! I just created a function to calculate my spawn points and connected the return value to the spawn transform pin.

As for my second issue, I used the “isvalid” macro to check to see if my child blueprint is valid or not and hooked the exe pin to a print string and it turns out, it’s not always valid for some reason, so the game decides to spawn me as my Parent Character Blueprint instead