Search code examples
c++unreal-engine4

Cast AActor to IGenericTeamAgentInterface | GetTeamAttitudeTowards


I want to implement/overwrite

virtual ETeamAttitude::Type GetTeamAttitudeTowards(const AActor& Other) 

in my controller. For that I need the opponents team id. For that I cast AActor& Other to check if it imlements the IGenericTeamAgentInterface.

const IGenericTeamAgentInterface* TeamAgent = Cast<IGenericTeamAgentInterface>(&Other);

But that returns something that is not true even if my Base unit inherits that interface.


Solution

  • Cast will return null if it cant cast to that class successfully (false on what your saying). Are you sure you are implementing any and all pure virtual and abstract functions in the base class AND implement the functions from the interface in the child class?