本文整理汇总了C++中GetPawn函数的典型用法代码示例。如果您正苦于以下问题:C++ GetPawn函数的具体用法?C++ GetPawn怎么用?C++ GetPawn使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetPawn函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnFire
void AZanshinAIController::OnFire()
{
AZanshinBot* character = Cast<AZanshinBot>(GetPawn());
if (character) {
character->OnFire(character->GetActorLocation(), character->GetActorRotation());
}
}
示例2: Possess
void AAIController::Possess(APawn* InPawn)
{
Super::Possess(InPawn);
if (!GetPawn())
{
return;
}
// no point in doing navigation setup if pawn has no movement component
const UPawnMovementComponent* MovementComp = InPawn->GetMovementComponent();
if (MovementComp != NULL)
{
UpdateNavigationComponents();
}
if (PathFollowingComponent)
{
PathFollowingComponent->Initialize();
}
if (bWantsPlayerState)
{
ChangeState(NAME_Playing);
}
OnPossess(InPawn);
}
示例3: GetPawn
/**
Function called to search for an enemy
- parameter void:
- returns: void
*/
void AEnemyController::SearchForEnemy()
{
APawn* MyEnemy = GetPawn();
if (MyEnemy == NULL)
return;
const FVector MyLoc = MyEnemy->GetActorLocation();
float BestDistSq = MAX_FLT;
ATankCharacter* BestPawn = NULL;
for (FConstPawnIterator It = GetWorld()->GetPawnIterator(); It; It++)
{
ATankCharacter* TestPawn = Cast<ATankCharacter>(*It);
if (TestPawn)
{
const float DistSq = FVector::Dist(TestPawn->GetActorLocation(), MyLoc);
bool canSee = LineOfSightTo(TestPawn);
//choose the closest option to the AI that can be seen
if (DistSq < BestDistSq && canSee)
{
BestDistSq = DistSq;
BestPawn = TestPawn;
}
}
}
if (BestPawn)
{
GEngine->AddOnScreenDebugMessage(0, 1.0f, FColor::Green, BestPawn->GetName());
SetEnemy(BestPawn);
}
}
示例4: GetPawn
void AMyPlayerController::SetNewMoveDestination(const FVector DestLocation)
{
if (!bIsPaused)
{
AMyAnt* MyAnt = Cast<AMyAnt>(UGameplayStatics::GetPlayerCharacter(this, 0));
APawn* const Pawn = GetPawn();
if (Pawn)
{
/*MyAnt->SetActorLocation(FMath::Lerp(MyAnt->GetActorLocation(), FVector(DestinationLocation.X, DestinationLocation.Y, MyAnt->GetActorLocation().Z), ToLocationCounter),true);
if (ToLocationCounter >= 1.0f)
{
MovingToLocation = false;
ToLocationCounter = 0;
}*/
UNavigationSystem* const NavSys = GetWorld()->GetNavigationSystem();
float const Distance = FVector::Dist(DestLocation, Pawn->GetActorLocation());
// We need to issue move command only if far enough in order for walk animation to play correctly
if (NavSys && (Distance > 120.0f))
{
NavSys->SimpleMoveToLocation(this, DestLocation);
}
}
}
}
示例5: GetFocalPoint
void AAIController::UpdateControlRotation(float DeltaTime, bool bUpdatePawn)
{
// Look toward focus
FVector FocalPoint = GetFocalPoint();
APawn* const Pawn = GetPawn();
if (Pawn)
{
FVector Direction = FAISystem::IsValidLocation(FocalPoint) ? (FocalPoint - Pawn->GetPawnViewLocation()) : Pawn->GetActorForwardVector();
FRotator NewControlRotation = Direction.Rotation();
// Don't pitch view unless looking at another pawn
if (Cast<APawn>(GetFocusActor()) == nullptr)
{
NewControlRotation.Pitch = 0.f;
}
NewControlRotation.Yaw = FRotator::ClampAxis(NewControlRotation.Yaw);
if (GetControlRotation().Equals(NewControlRotation, 1e-3f) == false)
{
SetControlRotation(NewControlRotation);
if (bUpdatePawn)
{
Pawn->FaceRotation(NewControlRotation, DeltaTime);
}
}
}
}
示例6: while
void ACinemotusPlayerController::OnSwichPawn(bool increase)
{
//Get Current Pawn's rotation?
if (PawnsInScene.Num() < 1)
{
return;
}
FString numstr = FString::Printf(TEXT("%d"), PawnsInScene.Num());
GEngine->AddOnScreenDebugMessage(-1, .5f, FColor::Yellow, numstr);
int startIndex = currentPawnIndex;
do
{
if (increase)
{
currentPawnIndex = currentPawnIndex + 1 < PawnsInScene.Num() ? currentPawnIndex + 1 : 0;
}
else
{
currentPawnIndex = currentPawnIndex - 1 < 0 ? PawnsInScene.Num() - 1 : currentPawnIndex - 1;
}
} while (PawnsInScene[currentPawnIndex]->bHidden && currentPawnIndex != startIndex); //keep going till we find a non hidden one
APawn* nextPawn = PawnsInScene[currentPawnIndex];
Possess(nextPawn);
SetViewTargetWithBlend(nextPawn, 0.0f);
possessedCinePawn = Cast<ACinemotusDefaultPawn>(nextPawn);
//GET JOYSTICK DATA
GetCineData(GetPawn());
}
示例7: releaseFrisbee
void AFrisbeeNulPlayerController::releaseFrisbee()
{
this->frisbee->unattachToPlayer();
this->frisbee->mesh->SetPhysicsLinearVelocity(FVector(0, 0, 0));
this->frisbee->mesh->AddForce(GetPawn()->GetActorForwardVector() * 10000000);
}
示例8: FindClosestEnemy
bool AMyAIController::FindClosestEnemy()
{
AMyChar* mySelf = Cast<AMyChar>(GetPawn());
if (!mySelf)
return false;
const FVector myLoc = mySelf->GetActorLocation();
float BestDistSq = MAX_FLT;
AMyChar * bestTarget = nullptr;
for (FConstPawnIterator iter = GetWorld()->GetPawnIterator(); iter; ++iter)
{
AMyChar* tmpTarget = Cast<AMyChar>(*iter);
if (tmpTarget != mySelf)
{
if (tmpTarget)
{
const float DistSq = (tmpTarget->GetActorLocation() - myLoc).SizeSquared();
if (DistSq < BestDistSq)
{
BestDistSq = DistSq;
bestTarget = tmpTarget;
FString str = FString::Printf(TEXT("--- find enemy dist:%f"), BestDistSq);
GEngine->AddOnScreenDebugMessage(0, 2.0f, FColor::Red, str);
}
}
}
}
if (bestTarget)
{
return SetEnemy(bestTarget);
}
return false;
}
示例9: GetPawn
void AFrisbeeNulPlayerController::MoveRight(float AxisValue)
{
APawn* const Pawn = GetPawn();
if (Pawn && this->frisbee->playerOwner != Pawn) {
Pawn->AddMovementInput(FVector::RightVector, FMath::Clamp<float>(AxisValue, -1.0f, 1.0f), false);
}
}
示例10: getFrisbee
void AFrisbeeNulPlayerController::getFrisbee()
{
this->frisbee->attachToPlayer(GetPawn());
this->frisbee->SetActorRelativeLocation(FVector(0, 0, 230));
}
示例11: GetPawn
void AMapPlayerController::CameraMoveRight(float d)
{
if (d != 0.0f)
{
GetPawn()->AddActorWorldOffset(FVector(0, CameraMoveDistance * d, 0));
}
}
示例12: FindNearestWaypoint
AMWWaypoint* AMWPatController::FindNearestWaypoint(bool bSetAsNext)
{
const AMWPat* pat = Cast<AMWPat>(GetPawn());
if (!pat)
{
return nullptr;
}
float minDist = MAX_FLT;
AMWWaypoint* nearestWp = nullptr;
// get all the waypoints in the level
TArray<AActor*> foundActors;
UGameplayStatics::GetAllActorsOfClass(this, AMWWaypoint::StaticClass(), foundActors);
if (!foundActors.Num())
{
UE_LOG(LogTemp, Error, TEXT("No waypoints in the level"));
return nullptr;
}
for (AActor* actor : foundActors)
{
const float dist = (pat->GetActorLocation() - actor->GetActorLocation()).SizeSquared();
AMWWaypoint* waypoint = Cast<AMWWaypoint>(actor);
const FString patTag = pat->WaypointTag;
const FString wpTag = waypoint->Tag;
// tags must match
if (dist < minDist && patTag == wpTag)
{
minDist = dist;
nearestWp = waypoint;
}
}
if (!nearestWp)
{
UE_LOG(LogTemp, Error, TEXT("Pat %s couldn't find a waypoint with matching tag %s"), *pat->GetName(), *pat->WaypointTag);
return nullptr;
}
// check whether we are already stand on that waypoint
// normally waypoints stay far away from each other, so there is only one possible overlapping at a given time
TArray<AActor*> overlaps;
pat->GetOverlappingActors(overlaps, AMWWaypoint::StaticClass());
if (overlaps.Num() && overlaps[0] == nearestWp)
{
check(nearestWp->Next)
nearestWp = nearestWp->Next;
}
if (nearestWp && bSetAsNext)
{
SetNextWaypoint(nearestWp);
}
return nearestWp;
}
示例13: GetPawn
void ASoftDesignTrainingPlayerController::OnTakeCoverPressed()
{
APawn* const Pawn = GetPawn();
if (Pawn)
{
FVector actorLocation = Pawn->GetActorLocation();
FRotator actorRotation = Pawn->GetActorRotation();
FVector coverTestStart = actorLocation;
FVector coverTestEnd = actorLocation + 400.0f * actorRotation.Vector();
UWorld* currentWorld = GetWorld();
static FName InitialCoverSweepTestName = TEXT("InitialCoverSweepTest");
FHitResult hitResult;
FQuat shapeRot = FQuat::Identity;
FCollisionShape collShape = FCollisionShape::MakeSphere(Pawn->GetSimpleCollisionRadius());
FCollisionQueryParams collQueryParams(InitialCoverSweepTestName, false, Pawn);
currentWorld->DebugDrawTraceTag = InitialCoverSweepTestName;
FCollisionObjectQueryParams collObjQueryParams(ECC_WorldStatic);
UDesignTrainingMovementComponent* charMovement = Cast<UDesignTrainingMovementComponent>(Pawn->GetMovementComponent());
if (currentWorld->SweepSingleByObjectType(hitResult, coverTestStart, coverTestEnd, shapeRot, collObjQueryParams, collShape, collQueryParams))
{
if (charMovement->ValidateCover(hitResult))
{
MoveToCoverDestination(hitResult.Location);
}
}
}
}
示例14: GetPawn
void AAIController::UnPossess()
{
APawn* CurrentPawn = GetPawn();
Super::UnPossess();
if (PathFollowingComponent)
{
PathFollowingComponent->Cleanup();
}
if (bStopAILogicOnUnposses)
{
if (BrainComponent)
{
BrainComponent->Cleanup();
}
}
if (CachedGameplayTasksComponent && (CachedGameplayTasksComponent->GetOwner() == CurrentPawn))
{
CachedGameplayTasksComponent->OnClaimedResourcesChange.RemoveDynamic(this, &AAIController::OnGameplayTaskResourcesClaimed);
CachedGameplayTasksComponent = nullptr;
}
OnUnpossess(CurrentPawn);
}
示例15: Finish
bool UPawnAction_Repeat::PushSubAction()
{
if (ActionToRepeat == NULL)
{
Finish(EPawnActionResult::Failed);
return false;
}
else if (RepeatsLeft == 0)
{
Finish(EPawnActionResult::Success);
return true;
}
if (RepeatsLeft > 0)
{
--RepeatsLeft;
}
UPawnAction* ActionCopy = SubActionTriggeringPolicy == EPawnSubActionTriggeringPolicy::CopyBeforeTriggering
? Cast<UPawnAction>(StaticDuplicateObject(ActionToRepeat, this, NULL))
: ActionToRepeat;
UE_VLOG(GetPawn(), LogPawnAction, Log, TEXT("%s> pushing repeted action %s %s, repeats left: %d")
, *GetName(), SubActionTriggeringPolicy == EPawnSubActionTriggeringPolicy::CopyBeforeTriggering ? TEXT("copy") : TEXT("instance")
, *GetNameSafe(ActionCopy), RepeatsLeft);
check(ActionCopy);
RecentActionCopy = ActionCopy;
return PushChildAction(*ActionCopy);
}