Proper way to check if an object is valid
I want to check if an object (UAudioComponent*) is valid so I can remove it from my array because the sound finished and the UAudioComponent will be destroyed, but when I use IsValid function it return
"Assertion failed: Index >= 0 [File:C:\Program Files\Epic Games\UE_4.22\Engine\Source\Runtime\CoreUObject\Public\UObject/UObjectArray.h] [Line: 661]
UE4Editor.exe has triggered a breakpoint."
because when the isValid function check if it is pending to kill, then access to an invalid index, so which is the best way to check if an object is valid or not? I will put pictures of the problem down there.
asked Jul 17 '19 at 09:21 AM in C++ Programming
I use Object->IsValidLowLevel()
You can also do a c++ nullptr check to see if it is able to be accessed.
answered Jul 17 '19 at 10:40 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here