引用c++ue4中的当兵玩家
Referencing pawn player in c++ ue4
对于一个项目,我正在设计一个坦克游戏,希望坦克能一直盯着我的玩家,但在网上看了很多之后,我还没有找到在c++中引用我的玩家的解决方案
ATank* myCharacter = Cast<ATank>(this);
if (myCharacter)
{
FVector targetLocation = myCharacter->GetActorLocation();
FVector myLocation = GetActorLocation();
FRotator newrot = (myLocation -targetLocation).Rotation();
NewRotation.Yaw = newrot.Yaw;
SetActorRotation(NewRotation);
}
以上是我目前所拥有的一切,因为它没有找到球员,在我发表if声明之前,它只是崩溃了,任何帮助/指导都是感谢和感谢的。
您可以使用UGameplayStatics::GetPlayerPawn(...)
UE文档,每个ATank
都可以保存它对您的典当的引用。然后,您应该检查存储的引用是否为null,并检查IsValidLowLevel()。下一步是使用玩家典当参考执行所需的计算。
相关文章:
- UE4-如何在给定4个屏幕坐标的情况下缩放纹理或材质
- 无法在UE4中包含BP类到CPP类
- UE4在OnComponentBeginOverlap上铸造其他actor
- UE4 C++ 我无法将 JSON 嵌套值获取到 TArray
- 根据用户回答声明"Players"。用户选择玩家数量。播放器是结构体
- 在UE4中使用未定义类型'UTextBlock'
- 玩家加速穿越世界(C++)
- C++:如何根据地形高度更新玩家身高?
- 预测玩家输赢,博弈论问题
- 指针相关的UE4崩溃.我的指针哪里错了?
- UE4(С++) 我找出按下了哪个键
- C++对玩家进行排序
- 安卓UE4错误缺少"SteamShared"的预编译清单
- C++ 如何处理所有可能的玩家移动输入?
- 玩家中的%是什么意思=(玩家%2)?1:2;
- UE4 - Visual Studio在我从编辑器添加新的c ++文件后无法打开任何源文件 - UBT_COMPILED
- UE4无法使用vs2017编译C++项目
- 为什么玩家控制器"own"偏航俯仰和滚动,但角色"owns"它的位置?
- 在UE4中,玩家进行光线投射、击中物体并触发自定义事件C++
- 引用c++ue4中的当兵玩家