将 AActor 转换为 IGenericTeamAgentInterface |获取团队态度

Cast AActor to IGenericTeamAgentInterface | GetTeamAttitudeTowards

本文关键字:获取 团队 态度 IGenericTeamAgentInterface AActor 转换      更新时间:2023-10-16

我想实现/覆盖

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

在我的控制器中。为此,我需要对手的球队ID。为此,我投射AActor&Other来检查它是否支持IGenericTeamAgentInterface。

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

但是,即使我的基本单元继承了该接口,也会返回不正确的内容。

如果 Cast 无法成功转换为该类,它将返回 null(根据你所说的错误(。您确定要在基类中实现任何和所有纯虚拟和抽象函数,并从子类中的接口实现函数吗?