diff --git a/Source/BlueprintComponentReference/BlueprintComponentReference.cpp b/Source/BlueprintComponentReference/BlueprintComponentReference.cpp index 8434310..28ce226 100644 --- a/Source/BlueprintComponentReference/BlueprintComponentReference.cpp +++ b/Source/BlueprintComponentReference/BlueprintComponentReference.cpp @@ -73,7 +73,7 @@ FString FBlueprintComponentReference::ToString() const return Result.ToString(); } -UActorComponent* FBlueprintComponentReference::GetComponent(AActor* SearchActor) const +UActorComponent* FBlueprintComponentReference::GetComponent(const AActor* SearchActor) const { UActorComponent* Result = nullptr; @@ -90,7 +90,8 @@ UActorComponent* FBlueprintComponentReference::GetComponent(AActor* SearchActor) break; case EBlueprintComponentReferenceMode::Path: // Variation 2: subobject path - Result = FindObjectFast(SearchActor, Value); + // const-cast is used as FindObjectFast does not provide a signature with const AActor* + Result = FindObjectFast(const_castSearchActor, Value); break; //case EBlueprintComponentReferenceMode::Dynamic: // Variation 3: dynamic selection diff --git a/Source/BlueprintComponentReference/BlueprintComponentReference.h b/Source/BlueprintComponentReference/BlueprintComponentReference.h index e434e32..3815fff 100644 --- a/Source/BlueprintComponentReference/BlueprintComponentReference.h +++ b/Source/BlueprintComponentReference/BlueprintComponentReference.h @@ -154,7 +154,7 @@ struct BLUEPRINTCOMPONENTREFERENCE_API FBlueprintComponentReference * * @param SearchActor Actor to perform search in */ - UActorComponent* GetComponent(AActor* SearchActor) const; + UActorComponent* GetComponent(const AActor* SearchActor) const; /** * Get the actual component pointer from this reference @@ -162,7 +162,7 @@ struct BLUEPRINTCOMPONENTREFERENCE_API FBlueprintComponentReference * @param SearchActor Actor to perform search in */ template - T* GetComponent(AActor* SearchActor) const + T* GetComponent(const AActor* SearchActor) const { return Cast(GetComponent(SearchActor)); }