当前位置: 首页>>代码示例>>C++>>正文


C++ GetPawn函数代码示例

本文整理汇总了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());
	}
}
开发者ID:JuanCCS,项目名称:Zanshin,代码行数:7,代码来源:ZanshinAIController.cpp

示例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);
}
开发者ID:Foreven,项目名称:Unreal4-1,代码行数:28,代码来源:AIController.cpp

示例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);
        
    }
}
开发者ID:burnsm,项目名称:Tanks,代码行数:40,代码来源:EnemyController.cpp

示例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);
			}
		}
	}
}
开发者ID:clairvoyantgames,项目名称:YOLA,代码行数:25,代码来源:MyPlayerController.cpp

示例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);
			}
		}
	}
}
开发者ID:Foreven,项目名称:Unreal4-1,代码行数:29,代码来源:AIController.cpp

示例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());

}
开发者ID:erinmichno,项目名称:CinemotusUE4,代码行数:31,代码来源:CinemotusPlayerController.cpp

示例7: releaseFrisbee

void AFrisbeeNulPlayerController::releaseFrisbee()
{
	this->frisbee->unattachToPlayer();

	this->frisbee->mesh->SetPhysicsLinearVelocity(FVector(0, 0, 0));
	this->frisbee->mesh->AddForce(GetPawn()->GetActorForwardVector() * 10000000);
}
开发者ID:Wincked,项目名称:FrisbeeNul,代码行数:7,代码来源:FrisbeeNulPlayerController.cpp

示例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;
}
开发者ID:yangxuan0261,项目名称:SlateSrc,代码行数:35,代码来源:MyAIController.cpp

示例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);
	}
}
开发者ID:Wincked,项目名称:FrisbeeNul,代码行数:7,代码来源:FrisbeeNulPlayerController.cpp

示例10: getFrisbee

void AFrisbeeNulPlayerController::getFrisbee()
{
	this->frisbee->attachToPlayer(GetPawn());


	this->frisbee->SetActorRelativeLocation(FVector(0, 0, 230));
}
开发者ID:Wincked,项目名称:FrisbeeNul,代码行数:7,代码来源:FrisbeeNulPlayerController.cpp

示例11: GetPawn

void AMapPlayerController::CameraMoveRight(float d)
{
  if (d != 0.0f)
  {
    GetPawn()->AddActorWorldOffset(FVector(0, CameraMoveDistance * d, 0));
  }
}
开发者ID:Milias,项目名称:ddsimulator,代码行数:7,代码来源:MapPlayerController.cpp

示例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;
}
开发者ID:Mingism,项目名称:MicroWave,代码行数:60,代码来源:MWPatController.cpp

示例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);
            }
        }
    }
}
开发者ID:UbisoftDirMet,项目名称:SoftDesignTraining,代码行数:32,代码来源:SoftDesignTrainingPlayerController.cpp

示例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);
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:27,代码来源:AIController.cpp

示例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); 
}
开发者ID:Foreven,项目名称:Unreal4-1,代码行数:29,代码来源:PawnAction_Repeat.cpp


注:本文中的GetPawn函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。