Why would this give me a warning..?

Experiencing a random glitch with my method of spawning actors based on Player Starts. Basically I’ve given each playerstart in the level a tag, and if it has the appropriate tag, it adds it to an array of possible spawnpoints. All of this functionality happens in the game mode, but when I begin play, I get this error, sometimes multiple times:

3211725d2d5fd7880282a3e9842ffa5e378400fb.jpeg

What’s odd is that it still kind of works… These are the scripts for the GameMode:

a859a8d888d03ce0fa7a2f08d8fdd1a1110be248.jpeg
7bae82aa11cf33df92759edc736de516ae0da76f.jpeg

Adding more Player Starts to the level with the right tags reduces the amount of times I get the issue, but it still crops up occasionally.

Probably start to check the “game start” before all object are loaded in the map. You can do it a cast to check that the class exist.

Well, I copy-pasted the sequence that gets all the player-starts in the level and used a begin play node instead. Now it’s just throwing me at the construction script node. WHY. There’s nothing in my construction script argh.

EDIT: I’ve tried everything now, I even did a check to remove anything that isn’t a playerstart from those arrays in the construction script as well. Still getting the occasional error. Makes no sense?!

when you loop an array, it should be index 0 to length-1, because unreal use 0 as first element array.

I tried that but still got the same error. I’ve rebuilt the nodes completely but now it points me to the ‘Branch’ nodes with errors instead. Something is definitely not right here…

I happen to my months ago, when errors in nodes or empty places I am struggle to remember how i resolve, it was very silly.

If you can’t be sure about what went wrong, check with isValid before you try to access or assign it to another variable.
Anything you get from an array index should be 0~length-1, including the random part to pick player start.

The problem is that your using “GetActorOfClass” in the construction script. Actor aren’t really registered until you play the game and only know about themselves, this results in the array being empty. Having said this though index 0 will be populated with “None” causing it to progress through the “ForEachLoop” once as it thinks there’s an item. Move it all into your main graph and have it come off the “Begin Play”, that should get rid of the error for you.

@pattym, that’s true if it was custom blueprint objects, however, it’s native playerstart class, what you said wouldn’t be a problem for OP.

Hmmmm. The only other place I can think that the “None” value is coming from is if you’ve added an index to the array in the “Defaults” tab. As you don’t clear the array before you add anything too it, the “None” value would stick around. It would explain why it wouldn’t pop up as much the more player starts you add.

Yea I did try that already, but it didn’t make any difference. The issue is sporadic, I even added some code that would filter through the Array and remove any ‘None’ entries before it got to the spawning part of the script, still had no luck :confused:

@TheJamsh, I have a question, is your error only happen once in a while when game starts, or once in a while when new player spawns(when PostLogin event is called)?

I recently run into some bug with UE4, I can’t reproduce it yet as it’s pretty random but it’s like this.

  1. you create a new variable in a blueprint
  2. you edit anything in the detail panel, somehow the editor will select another variable

I don’t know what triggers this behavior, but once it happens, it sticks until you close editor and open again.
And there are some slight chance that editor will crash when encounter this.

So, one test you can try is, if you close and open editor, does this error ever occur on the first time you PIE?(Just open and PIE, do nothing else.)
If you try say 10~20 times(depends on the frequency you get that error) and gets no error in first PIE, then maybe it’s some editor bug.
(on a side note, I bet many people already aware of this, that dynamically generated blue named object when PIE, they will accumulate in naming.
ie. for game mode, MyGame_C1, and then MyGame_C2, and continue to add numbers.)