List View Item not displaying on Event Begin Play

Hi,

I am having an issue where on event begin play certain ai are designated as ‘terrorists’ this same method is used later on when other ai change from civilian to terrorists and that works fine.
Then way the code is meant to work is it displays the description of the terrorist as a hud element once the event join terrorist cell is called. this is working perfectly for any of the ai if this is called during gameplay however it is not working on event begin play. Strangely the rest of the code that increments the number of terrorists and sets the ai to terrorist does indeed work on event begin play it’s only the call to the ui that seems to be failing. I even tried putting an additional call in just for the ones starting and that didn’t work.

Below is my blue print if anyone has any ideas as to why this might be the case id greatly appreciate it.

Which “Event Begin play” are you using? It might have something to do with initialisation order?

For instance if you call add health to player in say the game instance that initialises first, there is no character to add it to, so the code runs but doesn’t do everything it is supposed to do.

I’m just using the regular event begin play inside one of my actors.

I have two actors which on event begin play it should function like this
Actor A spawns actor B which generators some settings
actor B sends those 3 settings back to actor A
Actor A displays 1 of those settings as a list Item in the HUD

at the moment actor A is getting all of the variables passed through to it but for some reason it is not displaying that variable on the HUD even that that is the last order to be executed.

Strangely when this same call is made later in the game it does work.

Thanks for the reply, is there any other information you need to know?

For these kinds of bugs that only happen on Begin Play but not later when called again, it’s usually a matter of the Begin Play code being run before Actor B actually has a chance to spawn into the level. When trying to “call a second time” doesn’t work either, it’s because both calls are happening in the same frame so it doesn’t solve the problem. For a quick test, drop a Delay node before you are trying to run this logic and set the value to like 0.5. Then see if it works. If you don’t want the delay to affect any code you’re running after this step, just use a Sequence node and stick the delay and that chunk of logic on its own Then pin.

So you could try the suggestion of 1|2 Hawk and add a delay and se if that works? As they have said a similar thing to me in that it might just be that the actor is not available at the time of the call.

Other than that, as the rest of your code is apparently working; Check your order of operations.

Are you creating the HUD and adding it to viewport before you are asking it to update the text/list item?

Is the binding of the text set up to something that needs to be called to update? Or is it bound to a variable?

Have you tried calling the code in the game mode/ game instance/ player controller to see if calling the code in another BP?

You could try an IsValid? check before running the code, I.E make sure that the character is loaded and present in the level before it runs any code.

Actors/Pawns are not persistent, so data is destroyed if they are destroyed, when they join the terrorist cell does it affect them in any way?

Unfortunately there are a lot of moving parts and variables in this, so you might have to have a little play around and see, if where you call the code changes the outcome, when you call the code changes the outcome, ETC.

If the code works how you want it to, then I would say it strongly suggests it is an order of operation issue. Something is not being called in the right place and or time to update everything that it needs to.

I’ve tried a delay node and it has not made any difference, I’m certain all the actors are spawned by the time the delay is finished.