【发布时间】:2020-05-26 09:41:50
【问题描述】:
我尝试在虚幻引擎 C++ 中实现 RTS,目前我可以选择和取消选择单位,但它们不会移动,尽管我已经有一个功能。有人可以看看我做错了什么吗?这是我的代码:
void ACoba_PlayerController::SetupInputComponent()
{
Super::SetupInputComponent();
InputComponent->BindAction("RightMouseClick", IE_Pressed, this, &ACoba_PlayerController::MoveReleased);
}
void ACoba_PlayerController::MoveReleased()
{
if (SelectedActors.Num() > 0)
{
for (int32 i = 0; i < SelectedActors.Num(); i++)
{
FHitResult Hit;
GetHitResultUnderCursor(ECC_Visibility, false, Hit);
FVector MoveLocation = Hit.Location + FVector(i / 2 * 100, i % 2 * 100, 0);
UAIBlueprintHelperLibrary::SimpleMoveToLocation(SelectedActors[i]->GetController(), MoveLocation);
}
}
}
注意:我已经在 input 属性中设置了 RightMouseClick 的输入。
有人可以帮我吗。谢谢。
【问题讨论】:
标签: c++ unreal-engine4