Common validation check scripting problem

How do I fix validity check problem?

The nature of games with combat generally is to use destroy actor and have pending script. On surface it wouldn’t cause any problem other than the red warnings. But who knows right?
I could take different approach by using the method of hiding and disable the actors and reuse them later instead of spawn and destroy. But it’d take me sometime to make which doesn’t meet the current criteria.

Well it’s fine if there is no better ways to work around this problem, but if there are some other ways than I mentioned please do tell me since I wanted to know how others work around it.

Hey @DRAKOSEA1 , welcome to the forum

I’d like to point out something first. The “red warnings” are not warnings, those are errors that should have made the game crash, but Unreal Engine has a built in system to prevent Blueprints from crashing the editor.

Which means those should ALWAYS be fixed if you want to have a reliable game, otherwise if you ship it with those errors you’re shipping a bugged project that could have been prevented.


About the validation issue, there are ways to prevent that from being a problem and it’s ok to Spawn and Destroy actors, that shouldn’t be a blocker or a problem to the logic affecting or affected by those actors.

It’s not something that can be simply answered by saying “this is how you prevent validation issues” cause it always depends on the case, but generally you would build your systems and interactions in a way that prevents an actor from being used after you mark them to be destroyed.

How? You can have a system handling “available actors” and once they die, are destroyed or whatever remove them from the list so no one can interact with them.
You can have delegates (Dispatchers) for when a character spawns and for when it dies to handle this.

Usually you would have a “isAlive” boolean too on all characters to check for this before trying to deal damage to them or to do certain things only if they’re dead an so on…

It’s a matter of planning your code accordingly to what you want to accomplish keeping this things into consideration, which is true for any other aspect of a game.

Also, you have a couple Blueprint functions to check if an actor or a component is being destroyed in case you’re interesed. Can be good for testing errors in handling interactions and to pre-validate sometimes.
image

Hope that helps.

thanks for answering the question.
the pending destroy is kinda in many places, so I’m trying to streamline the functionality of each characters which could be destroyed.
gotta say it’s normally won’t cause anymore problem with just checking the validity of them, but it’d be more direct to check if they’re being destroyed in this case. though it’s still the same if we’re talking about the implementation.

seems like there is no alternative other than just check like this since this is how unreal handling the workflow.