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


C++ APawn类代码示例

本文整理汇总了C++中APawn的典型用法代码示例。如果您正苦于以下问题:C++ APawn类的具体用法?C++ APawn怎么用?C++ APawn使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了APawn类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: FName

void ADuckTower::Shoot(float distance)
{
	/*
	const FName filename = FName(TEXT("Blueprint'/Game/Blueprints/PickUp.PickUp'"));
	FVector loc = GetAttachParentActor()->GetActorLocation();
	FRotator rot = GetAttachParentActor()->GetActorRotation();
	SpawnBP(GetWorld(), (UClass*)LoadObjFromPath<UBlueprint>(&filename), loc, rot);
	*/
	APawn *player = UGameplayStatics::GetPlayerController(GetWorld(), 1)->GetControlledPawn();
	int randomValue = distance / 10000;
	FVector vec = player->GetActorLocation() + FVector(FMath::RandRange(-randomValue, randomValue), FMath::RandRange(-randomValue, randomValue), 0.0f); //+ player->GetRootPrimitiveComponent()->GetPhysicsLinearVelocity() *DeltaSeconds * 10;
	FVector vec2 = GetActorLocation();
	FVector Direction = vec - vec2;
	FRotator test = FRotationMatrix::MakeFromX(Direction).Rotator();
	FRotator test2 = FRotator(1.0f, 0.0f, 0.0f);
	FRotator finalrot = FRotator(test.Quaternion() * test2.Quaternion());


	FVector forward = GetActorForwardVector();
	finalrot.Roll = -finalrot.Roll;
	finalrot.Yaw = -finalrot.Yaw;
	finalrot.Pitch = -finalrot.Pitch;
	FVector loc = GetActorLocation() + forward * 500.0f;
	FRotator rot = GetActorRotation();
	AActor* actor = GetWorld()->SpawnActor<AActor>(BulletBlueprint, loc, GetActorRotation());
	actor->SetActorScale3D(FVector(3.0f, 3.0f, 3.0f));
	//actor->GetRootPrimitiveComponent()->AddImpulse(actor->GetActorForwardVector()* 5000.0f);

	//actor->GetRootPrimitiveComponent()->SetPhysicsLinearVelocity(actor->GetActorForwardVector()*10000.0f); //* (distance/10000 * 1.0f));
}
开发者ID:SlooBo,项目名称:RalliaPerkele,代码行数:30,代码来源:DuckTower.cpp

示例2: 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

示例3: GetPawn

void AFournoidAIController::FindClosestEnemy(){
	APawn* MyBot = GetPawn();
	if (MyBot == NULL)
	{
		return;
	}
	
	const FVector MyLoc = MyBot->GetActorLocation();
	float BestDistSq = MAX_FLT;
	AFournoidCharacter* BestPawn = NULL;
	
	for (FConstPawnIterator It = GetWorld()->GetPawnIterator(); It; ++It)
	{
		AFournoidCharacter* TestPawn = Cast<AFournoidCharacter>(*It);
		if (TestPawn && TestPawn->IsAlive() && TestPawn->GetController()->IsA(APlayerController::StaticClass()))
		{
			const float DistSq = (TestPawn->GetActorLocation() - MyLoc).SizeSquared();
			if (DistSq < BestDistSq &&  sqrt(DistSq) < 2500.f )
			{
				BestDistSq = DistSq;
				BestPawn = TestPawn;
			}
		}
	}
	
	if (BestPawn)
	{
		SetEnemy(BestPawn);
	}else {
		SetEnemy(NULL);
	}
}
开发者ID:Roger7410,项目名称:Fournoid,代码行数:32,代码来源:FournoidAIController.cpp

示例4: DebugNextPawn

void AGameplayDebuggingReplicator::DebugNextPawn(UClass* CompareClass, APawn* CurrentPawn)
{
#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
	APawn* LastSeen = nullptr;
	APawn* FirstSeen = nullptr;
	// Search through the list looking for the next one of this type
	for (FConstPawnIterator It = GetWorld()->GetPawnIterator(); It; It++)
	{
		APawn* IterPawn = *It;
		if (IterPawn->IsA(CompareClass))
		{
			if (LastSeen == CurrentPawn)
			{
				ServerSetActorToDebug(IterPawn);
				return;
			}
			LastSeen = IterPawn;
			if (FirstSeen == nullptr)
			{
				FirstSeen = IterPawn;
			}
		}
	}
	// See if we need to wrap around the list
	if (FirstSeen != nullptr)
	{
		ServerSetActorToDebug(FirstSeen);
	}
#endif
}
开发者ID:PopCap,项目名称:GameIdea,代码行数:30,代码来源:GameplayDebuggingReplicator.cpp

示例5: GetAttachParentActor

void ADuckTower::Tick(float DeltaSeconds)
{
	Super::Tick(DeltaSeconds);
	/*
	AActor *actor = GetAttachParentActor();
	FVector actor2 = UGameplayStatics::GetPlayerController(GetWorld(), 0)->GetControlledPawn()->GetActorLocation();
	FRotator newRotation = FRotationMatrix::MakeFromX(actor2 - actor->GetActorLocation()).Rotator();
	GetAttachParentActor()->SetActorRotation(newRotation);
	GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, actor->GetName());
	*//*
	FVector actor2 = UGameplayStatics::GetPlayerController(GetWorld(), 0)->GetControlledPawn()->GetActorLocation();
	FVector actor = GetAttachParentActor()->GetActorLocation();
	FVector Direction = actor - actor2;
	FRotator test = FRotationMatrix::MakeFromX(Direction).Rotator();
	GetAttachParentActor()->SetActorRotation(test);
	GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, actor2.ToString());
	*/
	//GetAttachParentActor()->SetActorLocation(FVector(0.0f, 0.0f, (float)testNumber));
	//testNumber += 1.f;
	APawn *player = UGameplayStatics::GetPlayerController(GetWorld(), 0)->GetControlledPawn();
	FVector actor2 = player->GetActorLocation(); //+ player->GetRootPrimitiveComponent()->GetPhysicsLinearVelocity() *DeltaSeconds * 10;
	FVector actor = GetActorLocation();
	FVector Direction = actor - actor2;
	FRotator test = FRotationMatrix::MakeFromX(Direction).Rotator();
	FRotator test2 = FRotator(1.0f, 0.0f, 0.0f);
	FRotator finalrot = FRotator(test.Quaternion() * test2.Quaternion());

	FVector vec2 = UGameplayStatics::GetPlayerController(GetWorld(), 0)->GetControlledPawn()->GetActorLocation();
	FVector vec = GetActorLocation();
	float distance = FVector::Dist(actor, actor2);

	//finalrot.Pitch -= 10 - distance / 10000 * 10;
	//SetActorRotation(finalrot);

	TArray<UStaticMeshComponent*> comps;
	GetComponents(comps);
	/*
	for (auto StaticMeshComponent : comps)
	{
	StaticMeshComponent->SetVisibility(true);
	StaticMeshComponent->SetWorldRotation(finalrot);
	GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, StaticMeshComponent->GetComponentRotation().ToString());
	}*/
	if (UGameplayStatics::GetPlayerController(GetWorld(), 0)->WasInputKeyJustPressed(EKeys::I))
	{

	}
	if (shootTimer <= 0.f)
	{


		Shoot(distance);
		shootTimer = 2.f;
	}
	else
		shootTimer -= DeltaSeconds;
	//GetAttachParentActor()->GetRootPrimitiveComponent()->AddImpulse(UGameplayStatics::GetPlayerController(GetWorld(), 0)->GetControlledPawn()->GetActorForwardVector());
	//GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, FString::FromInt(testNumber));
	//GetAttachParentActor()->SetActorRotation()
}
开发者ID:SlooBo,项目名称:RalliaPerkele,代码行数:60,代码来源:DuckTower.cpp

示例6: GetActorRotation

FExecStatus FCameraCommandHandler::GetActorRotation(const TArray<FString>& Args)
{
	APawn* Pawn = FUE4CVServer::Get().GetPawn();
	FRotator CameraRotation = Pawn->GetControlRotation();
	FString Message = FString::Printf(TEXT("%.3f %.3f %.3f"), CameraRotation.Pitch, CameraRotation.Yaw, CameraRotation.Roll);
	return FExecStatus::OK(Message);
}
开发者ID:Batname,项目名称:unrealcv,代码行数:7,代码来源:CameraHandler.cpp

示例7: GetActorLocation

FExecStatus FCameraCommandHandler::GetActorLocation(const TArray<FString>& Args)
{
	APawn* Pawn = FUE4CVServer::Get().GetPawn();
	FVector CameraLocation = Pawn->GetActorLocation();
	FString Message = FString::Printf(TEXT("%.3f %.3f %.3f"), CameraLocation.X, CameraLocation.Y, CameraLocation.Z);
	return FExecStatus::OK(Message);
}
开发者ID:Batname,项目名称:unrealcv,代码行数:7,代码来源:CameraHandler.cpp

示例8: SpawnAIFromClass

APawn* UAIBlueprintHelperLibrary::SpawnAIFromClass(UObject* WorldContextObject, TSubclassOf<APawn> PawnClass, UBehaviorTree* BehaviorTree, FVector Location, FRotator Rotation, bool bNoCollisionFail)
{
	APawn* NewPawn = NULL;

	UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject);
	if (World && *PawnClass)
	{
		FActorSpawnParameters ActorSpawnParams;
		ActorSpawnParams.bNoCollisionFail = bNoCollisionFail;
		NewPawn = World->SpawnActor<APawn>(*PawnClass, Location, Rotation, ActorSpawnParams);

		if (NewPawn != NULL)
		{
			if (NewPawn->Controller == NULL)
			{	// NOTE: SpawnDefaultController ALSO calls Possess() to possess the pawn (if a controller is successfully spawned).
				NewPawn->SpawnDefaultController();
			}

			if (BehaviorTree != NULL)
			{
				AAIController* AIController = Cast<AAIController>(NewPawn->Controller);

				if (AIController != NULL)
				{
					AIController->RunBehaviorTree(BehaviorTree);
				}
			}
		}
	}

	return NewPawn;
}
开发者ID:amyvmiwei,项目名称:UnrealEngine4,代码行数:32,代码来源:AIBlueprintHelperLibrary.cpp

示例9: GetCameraRotation

FExecStatus FCameraCommandHandler::GetCameraRotation(const TArray<FString>& Args)
{
	if (Args.Num() == 1)
	{
		bool bIsMatinee = false;

		FRotator CameraRotation;
		ACineCameraActor* CineCameraActor = nullptr;
		for (AActor* Actor : this->GetWorld()->GetCurrentLevel()->Actors)
		{
			// if (Actor && Actor->IsA(AMatineeActor::StaticClass())) // AMatineeActor is deprecated
			if (Actor && Actor->IsA(ACineCameraActor::StaticClass()))
			{
				bIsMatinee = true;
				CameraRotation = Actor->GetActorRotation();
				break;
			}
		}

		if (!bIsMatinee)
		{
			int32 CameraId = FCString::Atoi(*Args[0]); // TODO: Add support for multiple cameras
			APawn* Pawn = FUE4CVServer::Get().GetPawn();
			CameraRotation = Pawn->GetControlRotation();
		}

		FString Message = FString::Printf(TEXT("%.3f %.3f %.3f"), CameraRotation.Pitch, CameraRotation.Yaw, CameraRotation.Roll);

		return FExecStatus::OK(Message);
	}
	return FExecStatus::Error("Number of arguments incorrect");
}
开发者ID:Batname,项目名称:unrealcv,代码行数:32,代码来源:CameraHandler.cpp

示例10: check

//----------------------------------------------------------------------//
// FAITestSpawnInfo
//----------------------------------------------------------------------//
bool FAITestSpawnInfo::Spawn(AFunctionalAITest* AITest) const
{
	check(AITest);

	bool bSuccessfullySpawned = false;

	APawn* SpawnedPawn = UAIBlueprintHelperLibrary::SpawnAIFromClass(AITest->GetWorld(), PawnClass, BehaviorTree
		, SpawnLocation->GetActorLocation()
		, SpawnLocation->GetActorRotation()
		, /*bNoCollisionFail=*/true);

	if (SpawnedPawn == NULL)
	{
		FString FailureMessage = FString::Printf(TEXT("Failed to spawn \'%s\' pawn (\'%s\' set) ")
			, *GetNameSafe(PawnClass)
			, *SpawnSetName.ToString());

		UE_LOG(LogFunctionalTest, Warning, TEXT("%s"), *FailureMessage);
	}
	else if (SpawnedPawn->GetController() == NULL)
	{
		FString FailureMessage = FString::Printf(TEXT("Spawned Pawn %s (\'%s\' set) has no controller ")
			, *GetNameSafe(SpawnedPawn)
			, *SpawnSetName.ToString());

		UE_LOG(LogFunctionalTest, Warning, TEXT("%s"), *FailureMessage);
	}
	else
	{
		AITest->AddSpawnedPawn(*SpawnedPawn);
		bSuccessfullySpawned = true;
	}

	return bSuccessfullySpawned;
}
开发者ID:1vanK,项目名称:AHRUnrealEngine,代码行数:38,代码来源:FunctionalAITest.cpp

示例11: UE_LOG

void AVehicleSpawnerBase::SpawnVehicleAttempt()
{
	if(Vehicles.Num()>=NumberOfVehicles) 
	{
	  UE_LOG(LogCarla, Log, TEXT("All vehicles spawned correctly"));
	  return;
	}
	
	APlayerStart* spawnpoint = GetRandomSpawnPoint();
	APawn* playerpawn = UGameplayStatics::GetPlayerPawn(GetWorld(),0);
	const float DistanceToPlayer = playerpawn&&spawnpoint? FVector::Distance(playerpawn->GetActorLocation(),spawnpoint->GetActorLocation()):0.0f;
	float NextTime = TimeBetweenSpawnAttemptsAfterBegin;
	if(DistanceToPlayer>DistanceToPlayerBetweenSpawnAttemptsAfterBegin)
	{
	  if(SpawnVehicleAtSpawnPoint(*spawnpoint)!=nullptr)
	  {
	      UE_LOG(LogCarla, Log, TEXT("Vehicle %d/%d late spawned"), Vehicles.Num(), NumberOfVehicles);
	  }
	} else
	{
	  NextTime /= 2.0f;
	}
	
	if(Vehicles.Num()<NumberOfVehicles)
	{
	  auto &timemanager = GetWorld()->GetTimerManager();
	  if(AttemptTimerHandle.IsValid()) timemanager.ClearTimer(AttemptTimerHandle);
	  timemanager.SetTimer(AttemptTimerHandle,this, &AVehicleSpawnerBase::SpawnVehicleAttempt,NextTime,false,-1);
	} else
	{
	  UE_LOG(LogCarla, Log, TEXT("All vehicles spawned correctly"));
	}

}
开发者ID:cyy1991,项目名称:carla,代码行数:34,代码来源:VehicleSpawnerBase.cpp

示例12: DrawOverHeadInformation

void AGameplayDebuggingHUDComponent::DrawOverHeadInformation(APlayerController* PC, class UGameplayDebuggingComponent *DebugComponent)
{
#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
	APawn* MyPawn = Cast<APawn>(DebugComponent->GetSelectedActor());
	const FVector Loc3d = MyPawn ? MyPawn->GetActorLocation() + FVector(0.f, 0.f, MyPawn->GetSimpleCollisionHalfHeight()) : FVector::ZeroVector;

	if (OverHeadContext.Canvas->SceneView == NULL || OverHeadContext.Canvas->SceneView->ViewFrustum.IntersectBox(Loc3d, FVector::ZeroVector) == false)
	{
		return;
	}

	const FVector ScreenLoc = OverHeadContext.Canvas->Project(Loc3d);
	static const FVector2D FontScale(1.f, 1.f);
	UFont* Font = GEngine->GetSmallFont();

	float TextXL = 0.f;
	float YL = 0.f;
	FString ObjectName = FString::Printf( TEXT("{yellow}%s {white}(%s)"), *DebugComponent->ControllerName, *DebugComponent->PawnName);
	CalulateStringSize(OverHeadContext, OverHeadContext.Font, ObjectName, TextXL, YL);

	bool bDrawFullOverHead = MyPawn != nullptr && GetDebuggingReplicator()->GetSelectedActorToDebug() == MyPawn;
	float IconXLocation = OverHeadContext.DefaultX;
	float IconYLocation = OverHeadContext.DefaultY;
	if (bDrawFullOverHead)
	{
		OverHeadContext.DefaultX -= (0.5f*TextXL*FontScale.X);
		OverHeadContext.DefaultY -= (1.2f*YL*FontScale.Y);
		IconYLocation = OverHeadContext.DefaultY;
		OverHeadContext.CursorX = OverHeadContext.DefaultX;
		OverHeadContext.CursorY = OverHeadContext.DefaultY;
	}

	if (DebugComponent->DebugIcon.Len() > 0)
	{
		UTexture2D* RegularIcon = (UTexture2D*)StaticLoadObject(UTexture2D::StaticClass(), NULL, *DebugComponent->DebugIcon, NULL, LOAD_NoWarn | LOAD_Quiet, NULL);
		if (RegularIcon)
		{
			FCanvasIcon Icon = UCanvas::MakeIcon(RegularIcon);
			if (Icon.Texture)
			{
				const float DesiredIconSize = bDrawFullOverHead ? 32.f : 16.f;
				DrawIcon(OverHeadContext, FColor::White, Icon, IconXLocation, IconYLocation - DesiredIconSize, DesiredIconSize / Icon.Texture->GetSurfaceWidth());
			}
		}
	}

	if (bDrawFullOverHead)
	{
		OverHeadContext.FontRenderInfo.bEnableShadow = bDrawFullOverHead;
		PrintString(OverHeadContext, bDrawFullOverHead ? FColor::White : FColor(255, 255, 255, 128), FString::Printf(TEXT("%s\n"), *ObjectName));
		OverHeadContext.FontRenderInfo.bEnableShadow = false;
	}

	if (EngineShowFlags.DebugAI)
	{
		DrawPath(PC, DebugComponent);
	}
#endif //!(UE_BUILD_SHIPPING || UE_BUILD_TEST)
}
开发者ID:JustDo1989,项目名称:UnrealEngine4.11-HairWorks,代码行数:59,代码来源:GameplayDebuggingHUDComponent.cpp

示例13: GetAIController

AAIController* UAIBlueprintHelperLibrary::GetAIController(AActor* ControlledActor)
{
	APawn* AsPawn = Cast<APawn>(ControlledActor);
	if (AsPawn != nullptr)
	{
		return Cast<AAIController>(AsPawn->GetController());
	}
	return Cast<AAIController>(ControlledActor);
}
开发者ID:amyvmiwei,项目名称:UnrealEngine4,代码行数:9,代码来源:AIBlueprintHelperLibrary.cpp

示例14: OwnerIsLocallyControlled

bool FGameplayCueHandler::OwnerIsLocallyControlled() const
{
	APawn* Pawn = Cast<APawn>(Owner);
	if (Pawn)
	{
		return Pawn->IsLocallyControlled();
	}

	return false;
}
开发者ID:1vanK,项目名称:AHRUnrealEngine,代码行数:10,代码来源:GameplayCueView.cpp

示例15: TryGetPawnOwner

void UMyAnimInstance::NativeUpdateAnimation(float DeltaSeconds)
{
	Super::NativeUpdateAnimation(DeltaSeconds);

	APawn* OwningPawn = TryGetPawnOwner();
	if (OwningPawn)
	{
		Speed = OwningPawn->GetVelocity().Size();
	}
}
开发者ID:wahidshafique,项目名称:GAME2013,代码行数:10,代码来源:MyAnimInstance.cpp


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