发布网友
共1个回答
热心网友
1,获取鼠标在当前场景中坐标系统的中的position,加入场景地图的范围是一千平方米,那么这个position的范围也是1000米x1000米。
注册鼠标事件
Cpp代码
FInputActionBinding &action1 = InputComponent->BindAction("SetDestination", IE_Pressed, this, &AHPlayerController::OnSetDestinationPressed);
函数实现MoveToMouseCursor(),此函数放在PlayerController::PlayerTick()内调用,重写下PlayerTick():
Cpp代码
void AHPlayerController::MoveToMouseCursor()
{
// Trace to see what is under the mouse cursor
FHitResult Hit;
GetHitResultUnderCursor(ECC_Visibility, false, Hit);
if (Hit.bBlockingHit)
{
// We hit something, move there
SetNewMoveDestination(Hit.ImpactPoint);
}
}