标签:get result ast eth color const false cto vector
控制鼠标单击的物体
void AMyCharacter::PossesClicked() { APlayerController* PlayerController = Cast<APlayerController>(GetController()); if (PlayerController != nullptr) { // Get the coordinates of the mouse from our controller float LocationX; float LocationY; PlayerController->GetMousePosition(LocationX, LocationY); // Do a trace and see if there the position intersects something in the world FVector2D MousePosition(LocationX, LocationY); FHitResult HitResult; const bool bTraceComplex = false; if (PlayerController->GetHitResultAtScreenPosition(MousePosition, ECC_Visibility, bTraceComplex, HitResult) == true ) { // If the actor we intersected with is a controller posses it APawn* ClickedPawn = Cast<APawn>(HitResult.GetActor()); if( ClickedPawn != nullptr ) { // Unposses ourselves PlayerController->UnPossess(); // Posses the controller we clicked on PlayerController->Possess(ClickedPawn); } } } }
标签:get result ast eth color const false cto vector
原文地址:http://www.cnblogs.com/hanliu/p/6561092.html