void AEventExampleProjectPlayerController::SelectableClicked(AActor *pClicked) { if (pClicked) { SetNewMoveDestination(pClicked->GetActorLocation()); } }
void AMainPlayerController::PlayerTick(float DeltaTime) { Super::PlayerTick(DeltaTime); if (clickedPawn != nullptr ) { SetNewMoveDestination(); } }
void ATopDown_HitmanCleanPlayerController::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); } }
void ATopDown_HitmanCleanPlayerController::MoveToTouchLocation(const ETouchIndex::Type FingerIndex, const FVector Location){ FVector2D ScreenSpaceLocation(Location); // Trace to see what is under the touch location FHitResult HitResult; GetHitResultAtScreenPosition(ScreenSpaceLocation, CurrentClickTraceChannel, true, HitResult); if (HitResult.bBlockingHit){ // We hit something, move there SetNewMoveDestination(HitResult.ImpactPoint); } }
void AMyPlayerController::MoveToMouseCursor() { if (!bIsPaused) { // Trace to see what is under the mouse cursor FHitResult Hit; GetHitResultUnderCursor(ECC_Visibility, false, Hit); APawn* const Pawn = GetPawn(); //float const Distance = FVector::Dist(DestinationLocation, Pawn->GetActorLocation()); if (Hit.bBlockingHit) { DestinationLocation = Hit.ImpactPoint; // We hit something, move there SetNewMoveDestination(DestinationLocation); MovingToLocation = true; } } }