FWeakObjectPtr / TWeakObjectPtr::IsValid (API)
source: https://dev.epicgames.com/documentation/en-us/unreal-engine/API/Runtime/CoreUObject/FWeakObjectPtr ; https://dev.epicgames.com/documentation/en-us/unreal-engine/API/Runtime/Core/TWeakObjectPtr/IsValid version: Unreal Engine 5.8 API Reference (WebFetch) fetched: 2026-10-11
Excerpts
- FWeakObjectPtr is a weak pointer to a UObject. It can return nullptr later if the object is garbage collected. It has no impact on if the object is garbage collected or not. It can't be directly used across a network.
- Most often it is used when you explicitly do NOT want to prevent something from being garbage collected.
- Header: /Engine/Source/Runtime/CoreUObject/Public/UObject/WeakObjectPtr.h ; TWeakObjectPtr: UObject/WeakObjectPtrTemplates.h
- Protected members: ObjectIndex (int32), ObjectSerialNumber (int32).
- Get(): Dereference the weak pointer. GetEvenIfUnreachable(). IsExplicitlyNull(): true if explicitly assigned to null, reset, or never initialized.
- IsStale(bIncludingGarbage, bThreadsafeTest): Slightly different than !IsValid(), returns true if this used to point to a UObject, but doesn't any more and has not been assigned or reset in the mean time.
- Pin(): Get a strong object ptr (TStrongObjectPtr
). TryPin(bOutPinValid): Attempt to get a strong object ptr, but only if garbage collection is not in progress. - operator bool(): This is explicitly not added to avoid resolving weak pointers too often - use Get() once in a function.
- TWeakObjectPtr::IsValid(): Test if this points to a live UObject ... This should be done only when needed as excess resolution of the underlying pointer can cause performance issues. Note that IsValid can not be used on another thread as it will incorrectly return false during the mark phase of the GC due to the Unreachable flag being set.
- bThreadsafeTest: if true then function will just give you information whether referenced UObject is gone forever (return false) or if it is still there (return true, no object flags checked).