Storing references after level loading

Hello, everyone!

I am having an issue when I try to save references, in my game mode class, of actors spawned in level. I want to save a reference to “Track”, the only actor in the world with that tag, but although the level loads, I still get an error when I call Init(), which is called by StartGame(). It detects no actors at all, triggering my “ensureAlways” assert. Any thoughts?

PS: I am really close to my deadline, so please keep it simple.

It may be possible that the GameMode init function is called before any of the actors are in memory. Perhaps try to add a delay node with a small value( e.g 0.1 - 0.01s) before you call the StartGame function, this will ensure that the actors will be in memory before the init function is called.

@MutatePat I tried adding a delay but for some reason it doesn’t work

Alright, guess I’ll have to recreate your problem then. I’ll get back to you soon, though hopefully somebody already has the solution :slight_smile:

Hey guys, a friend of mine helped me fix the issue by checking if all the actors were loaded every time I added them. Then, adding a check on tick if everything was loaded with a boolean flag. I know I should probably use delegates, but time is of the essence here. Thanks offering help, and I hope this helps someone in the future!! I included screenshots of my temporary solution.

Glad to hear you found a solution :slight_smile:
For future readers, tick should be used sparingly and could be replaced with a looping timer in most cases, though this tick function doesn’t seem very heavy so it’ll be fine.