Confirming that a UObject is valid is an important aspect of Unreal Engine development. If you attempt to manipulate or use the UObject while it's invalid, you can come across issues. And in more severe cases, engine crashes.
There are multiple methods on how to approach this —-
If you end up finding this article useful — spread the word!
Method #1 - Is Valid Macro
This method is a built-in macro that outputs an
IsValid and an
Is Not Valid execution path. Useful what occurs based on if the UObject is valid or not.
Method #2 - Validated Get
This method is more of a hidden method that a lot of Unreal Engine developers haven't stumbled across yet. It basically combines a given Variable with the above
Is Valid Macro. Extremely useful for cleaning up blueprint layouts.
To convert a Variable to a Validated Get —-
- Right click variable node
- At the bottom of the right-click action menu, click
Convert to Validated Get
Method #3 - Is Valid Getter
This method returns a Boolean that states wither the UObject is valid or not. Useful when batching together multiple arguments.
Thank you for reading!
My goal with Unreal Directive is to provide an extremely useful and easy to understand resource for Unreal Engine developers across all skill levels. Therefore, if you have found this article useful, spread the word! Please share it with your developer friends and peers. If you have a suggestion, or have come across an issue with the article, please message me via Twitter or via email.