• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ GetPawn函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了GetPawn函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: UE_LOG

void ATankAIController::onPossedTankDeath()
{
	UE_LOG(LogTemp, Warning, TEXT("%s Is Dead"), *GetPawn()->GetName())

	possessedTank->DetachFromControllerPendingDestroy();

}
开发者ID:Unreal-Learning-Courses,项目名称:Udemy-UE-Cplusplus-Section-04,代码行数:7,代码来源:TankAIController.cpp


示例17: UE_LOG

FPathFollowingRequestResult AWalkerAIController::MoveTo(
      const FAIMoveRequest& MoveRequest,
      FNavPathSharedPtr* OutPath)
{
#ifdef CARLA_AI_WALKERS_EXTRA_LOG
  UE_LOG(LogCarla, Log, TEXT("Walker %s requested move from (%s) to (%s)"),
      *GetPawn()->GetName(),
      *GetPawn()->GetActorLocation().ToString(),
      *MoveRequest.GetGoalLocation().ToString())

;
#endif // CARLA_AI_WALKERS_EXTRA_LOG
  
  ChangeStatus(EWalkerStatus::Moving);
  return Super::MoveTo(MoveRequest, OutPath);
}
开发者ID:cyy1991,项目名称:carla,代码行数:16,代码来源:WalkerAIController.cpp


示例18: GetPawn

void ACinemotusPlayerController::AbsoluteTick(float DeltaTime)
{

	
	TotalYawAbs += addYaw;
	UPrimitiveComponent* prim = GetPawn()->GetMovementComponent()->UpdatedComponent;
	//USceneComponent* sComponent = GetPawn()->GetRootComponent();
	//sComponent->SetRelativeLocation;

	bool SetPrimDirectly = true;
	FQuat finalQuat;

	if (((currentCaptureState&ECinemotusCaptureState::EAbsolute) == ECinemotusCaptureState::EAbsolute) && 
		((currentCaptureState&ECinemotusCaptureState::EAbsoluteOff) == 0))
	{
		finalQuat = FRotator(0, TotalYawAbs, 0).Quaternion()*(HydraLatestData->controllers[CAM_HAND].quat);
	}
	else
	{
		finalQuat =  FRotator(0, addYaw, 0).Quaternion()*prim->GetComponentQuat();
	}
	SetControlRotation(finalQuat.Rotator());
	if (SetPrimDirectly && prim)
	{
		prim->SetWorldLocationAndRotation(prim->GetComponentLocation(), finalQuat);// not sure need
	}


	HandleMovementAbs(DeltaTime, ((currentCaptureState&ECinemotusCaptureState::EAbsolute) == ECinemotusCaptureState::EAbsolute));
}
开发者ID:erinmichno,项目名称:CinemotusUE4,代码行数:30,代码来源:CinemotusPlayerController.cpp


示例19: FHitResult

void ALMPlayerController::PawnRotationToTarget()
{
    if (this->bIsRotationChange)
    {
        FHitResult CursorHitRes = FHitResult();
        if (GetHitResultUnderCursor(ECollisionChannel::ECC_Visibility, false, CursorHitRes))
        {
            FVector FaceDir = CursorHitRes.Location - GetPawn()->GetActorLocation();
            FRotator FaceRotator = FaceDir.Rotation();
            FaceRotator.Pitch = 0;
            FaceRotator.Roll = 0;
            GetPawn()->SetActorRotation(FaceRotator);
        }
    }

}
开发者ID:willcong,项目名称:LonelyMen,代码行数:16,代码来源:LMPlayerController.cpp


示例20: GetPawn

void ATankAIController::Tick(float DeltaSeconds)
{
	Super::Tick(DeltaSeconds);
	auto aiTank = GetPawn();
	auto playerTank = GetWorld()->GetFirstPlayerController()->GetPawn();
	if (ensure(playerTank)) {

		// TODO Move towards the player
		MoveToActor(playerTank, acceptanceRadius); // TODO check radius is in cm

		// Aim towards the player
		auto aimComponent = aiTank->FindComponentByClass<UTankAimingComponent>();
		aimComponent->AimAt(playerTank->GetActorLocation());
		

		//GetPawn().reloadTimeInSeconds = 10;
		// Fire if ready
		if (aimComponent->GetFiringState() == EFiringStatus::Ready) {
			aimComponent->Fire();
			//UE_LOG(LogTemp,Warning,TEXT("AI Tank Ready and Firing!"))
		}


		
	}

}
开发者ID:Unreal-Learning-Courses,项目名称:Udemy-UE-Cplusplus-Section-04,代码行数:27,代码来源:TankAIController.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ GetPciAddress函数代码示例发布时间:2022-05-30
下一篇:
C++ GetPathName函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap