게임 개발/Unreal Engine
[UE5] FHitResult의 Actor 문제 해결
지노윈
2022. 3. 12. 09:47
FHitResult의 Actor는 GetActor()로 변경 되었습니다.
UE4 코드
UE4에서는 WeakPointer를 기반 하였습니다. (TWeakObjectPtrBase::Get(), TWeakObjectPtrBase::IsValid())
TArray<AActor*> collidedActors;
for (auto& hitResult : HitResults)
{
if (!hitResult.bBlockingHit && hitResult.Actor.IsValid())
{
collidedActors.Add(hitResult.Actor.Get());
}
}
UE5 코드
WeakPointer에서 FActorInstanceHandle로 구현이 변경 되었습니다.
TArray<AActor*> collidedActors;
for (auto& hitResult : HitResults)
{
if (!hitResult.bBlockingHit && hitResult.GetActor())
{
collidedActors.Add(hitResult.GetActor());
}
}
// UE5
FORCEINLINE AActor* GetActor() const
{
return HitObjectHandle.FetchActor();
}
FActorInstanceHandle의 설명은 다음과 같습니다.
Handle to a unique object. This may specify a full weigh actor or it may only specify the light weight instance that represents the same object.
내부 구현을 보면 FActorInstanceHandle역시 WeakPointer에 기반 하는 것을 알 수 있습니다.
USTRUCT(BlueprintType)
struct ENGINE_API FActorInstanceHandle
{
...
/** this is cached here for convenience */
UPROPERTY()
mutable TWeakObjectPtr<AActor> Actor;
/** Identifies the light weight instance manager to use */
TWeakObjectPtr<ALightWeightInstanceManager> Manager;
...
};
반응형