I’m working on a game for Oculus Quest 2 and am trying to spawn components from C++ and create a Pooling system. The code works fine in PIE, but won’t spawn any components or actors whenever I try to.
The code is supposed to check an array to check whether there’s a vacant object to reuse, and spawn another one if not:
What am I doing wrong? I’ve put multiple checks to see if the class itself is working and the values retrieved from the function, which seems to be valid until the next node, where the log tells me there are a lot of “Accessed None” errors.
Ok found a solution. You need to add a slight delay in the init function. The pooler seems to spawn correctly then & the rest works.
Works in shipping pack too.
Well, since knowing about the delay and trying the timer in C++, I dug up some more and found this post, where the OP is trying to achieve basically the same as I am, but the World doesn’t exist at the time the Instance Init() is called, which brings me a lot of issues and unwanted errors, so I guess I’ll have to place it somewhere else other than the Instance
The GameMode or even PlayerController should work just fine for that though, so I’ll just try some stuff and check what works best!
From the life cycle flow chart I would probably to with Game Mode Base => Begin Play
The world should be initialed at that point and it’s a singleton so easier to keep track of…
Putting it into the GameMode worked as a charm! The only issue is that the execution order for some reason in the Editor is different than Packaged, not so much of a hassle, but it’s good to keep that in mind.