I’m trying to call an overridden function using a reference to an actor that is that class, though the pointer is a parent of that class, I don’t think that should matter. This is my code:
// ParentPiece.h
UFUNCTION(BlueprintPure, Category=“Active Ability”)
virtual TArray<AActor*> GetValidActiveAbilityTargets();// Knight.h (AKnight is a child of AParentPiece
virtual TArray<AActor*> GetValidActiveAbilityTargets() override;// MyPlayerPawn.cpp
AParentPiece* SelectedPiece = /* Gets a pointer to an AKnight actor. Debugging confirms that this variable is set to an actor of the type AKnight. */// This Calls AParentPiece::GetValidActiveAbilityTargets(), not AKnight::GetValidActiveAbilityTargets.
SelectedPiece->GetValidActiveAbilityTargets();
Hopefully that shows enough of what’s happening. If you need more, I have a GitHub repository, but it would be difficult to dissect this bit of code when seeing the entire codebase for the first time.
Does anyone know why this might happen?
Thanks in advance!
Edit: It may be worth noting that SelectedPiece is actually a BP_Knight_C object, not an AKnight object. BP_Knight is a direct child of AKnight, which is a direct child of AParentPiece, so it shouldn’t matter, right?