Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/135.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/design-patterns/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 向IGenericTeamAgentInterface投射一个角色|向上获得团队态度_C++_Unreal Engine4 - Fatal编程技术网

C++ 向IGenericTeamAgentInterface投射一个角色|向上获得团队态度

C++ 向IGenericTeamAgentInterface投射一个角色|向上获得团队态度,c++,unreal-engine4,C++,Unreal Engine4,我想实现/覆盖 virtual ETeamAttitude::Type GetTeamAttitudeTowards(const AActor& Other) 在我的控制器里。为此,我需要对手的球队id。 为此,我使用AActor&Other来检查它是否包含IGenericTeamAgentInterface const IGenericTeamAgentInterface* TeamAgent = Cast<IGenericTeamAgentInterface>(&am

我想实现/覆盖

virtual ETeamAttitude::Type GetTeamAttitudeTowards(const AActor& Other) 
在我的控制器里。为此,我需要对手的球队id。 为此,我使用AActor&Other来检查它是否包含IGenericTeamAgentInterface

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

但即使我的基本单元继承了那个接口,它也会返回一些不正确的结果

Cast如果不能成功地转换到该类,将返回null(你说的是false)。您确定要在基类中实现任何和所有纯虚函数和抽象函数,并在子类中从接口实现函数吗?

您是否尝试过Cast(Other)?不确定是否需要通过引用传递。谢谢,但不起作用:重载“Cast”的实例与参数列表不匹配。参数类型是(const AACtor)您最初得到的错误是什么?你说“它会返回一些不真实的东西”,但你会说什么?TeamAgent是否为空?你有编译错误吗?我基本上没有编译错误,但是由于没有返回true,所以计算结果为false(现在无法检查),这意味着其他人没有实现该接口,buuuut因为我在那个场景中使用的每个演员都继承了我实现的baseActor,并且那个演员确实实现了那个interfaceCast,所以如果它不能成功地转换到那个类,它将返回null(你说的是false)。您确定要在基类中实现任何和所有纯虚函数和抽象函数,并在子类中从接口实现这些函数吗?