本文整理汇总了C++中AAIController::RunBehaviorTree方法的典型用法代码示例。如果您正苦于以下问题:C++ AAIController::RunBehaviorTree方法的具体用法?C++ AAIController::RunBehaviorTree怎么用?C++ AAIController::RunBehaviorTree使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AAIController
的用法示例。
在下文中一共展示了AAIController::RunBehaviorTree方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: Change
void AChangeable::Change()
{
FActorSpawnParameters SpawnParameters = FActorSpawnParameters();
SpawnParameters.bNoCollisionFail = true;
APawn* Pawn = GetWorld()->SpawnActor<APawn>(TargetClass, GetActorLocation(), GetActorRotation(), SpawnParameters);
if (Pawn)
{
if (Pawn->Controller)
{
Pawn->SpawnDefaultController();
}
if (BehaviorTree != NULL)
{
AAIController* AIController = Cast<AAIController>(Pawn->Controller);
if (AIController != NULL)
{
AIController->RunBehaviorTree(BehaviorTree);
}
}
}
Destroy();
}
示例3: SpawnAI
APawn* UKismetAIHelperLibrary::SpawnAI(class UObject* WorldContextObject, UBlueprint* Pawn, class UBehaviorTree* BehaviorTree, FVector Location, FRotator Rotation, bool bNoCollisionFail)
{
APawn* NewPawn = NULL;
UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject);
if (World && Pawn && BehaviorTree)
{
FActorSpawnParameters ActorSpawnParams;
ActorSpawnParams.bNoCollisionFail = bNoCollisionFail;
NewPawn = World->SpawnActor<APawn>(Pawn->GeneratedClass, Location, Rotation, ActorSpawnParams);
ActorSpawnParams.bNoCollisionFail = true;
if (NewPawn != NULL)
{
if (NewPawn->Controller == NULL)
{
AAIController* NewController = World->SpawnActor<AAIController>(AAIController::StaticClass(), ActorSpawnParams);
if (NewController)
{
NewController->Possess(NewPawn);
}
}
AAIController* AIController = Cast<AAIController>(NewPawn->Controller);
if (AIController != NULL)
{
AIController->RunBehaviorTree(BehaviorTree);
}
}
}
return NewPawn;
}
示例4: SpawnRandomEnemy
void ASpawnEnemy::SpawnRandomEnemy()
{
TArray<FString> Parsed;
TArray<FString> HowMuch;
TArray<FString> TypeEnemy;
const TCHAR* Delims[] = { TEXT(":"), TEXT(";") };
float RandomNumber = (float)rand() / (float)RAND_MAX;
int SetNumber = RandomNumber * (Enemies.Num());
Enemies[SetNumber].ParseIntoArray(&Parsed, Delims, 2);
int SizeOfArrayParsed = Parsed.Num() - 1;
for (int x = 0; x <= SizeOfArrayParsed; x = x + 2) {
HowMuch.Add(Parsed[x]);
}
for (int x = 1; x <= SizeOfArrayParsed; x = x + 2) {
TypeEnemy.Add(Parsed[x]);
}
for (auto Itr(HowMuch.CreateIterator()); Itr; Itr++) {
APawn* NewPawn = NULL;
FVector BoxOnWorld = GetActorLocation();
FRotator RotatorBoxOnWorld = GetActorRotation();
FBox BoxInfo = GetComponentsBoundingBox();
FVector BoxSize = BoxInfo.GetSize();
if (TypeEnemy[Itr.GetIndex()] == "PegEnemyLight")
{
EnemyClass = PegLightEnemyClass;
}
else if (TypeEnemy[Itr.GetIndex()] == "PegDarkEnemy") {
EnemyClass = PegDarkEnemyClass;
}
else if (TypeEnemy[Itr.GetIndex()] == "GarbageEnemy") {
EnemyClass = GarbageEnemyClass;
}
else if (TypeEnemy[Itr.GetIndex()] == "MeleeBookEnemy") {
EnemyClass = MeleeBookEnemyClass;
}
else if (TypeEnemy[Itr.GetIndex()] == "RangeBookEnemy") {
EnemyClass = RangeBookEnemyClass;
}
else if (TypeEnemy[Itr.GetIndex()] == "PianoChargeEnemy") {
EnemyClass = PianoEnemyClass;
}
else if (TypeEnemy[Itr.GetIndex()] == "BarrelChargeEnemy") {
EnemyClass = BarrelEnemyClass;
}
else if (TypeEnemy[Itr.GetIndex()] == "FridgeChargeEnemy") {
EnemyClass = FridgeEnemyClass;
}
if (GetWorld())
{
int32 MyShinyNewInt = FCString::Atoi(*HowMuch[Itr.GetIndex()]);
for (int x = 1; x <= MyShinyNewInt; x++) {
float random = (float)rand() / (float)RAND_MAX;
float randomy = (float)rand() / (float)RAND_MAX;
int xValue = 1 + random * ((3) - (1));
int yValue = 1 + randomy * ((3) - (1));
float z, y;
if (xValue == 1)
z = random * (0 + (BoxSize[0] / 2));
else
z = random * (0 - (BoxSize[0] / 2));
if (yValue == 1)
y = random * (0 + (BoxSize[1] / 2));
else
y = random * (0 - (BoxSize[1] / 2));
BoxOnWorld[0] += z;
BoxOnWorld[1] += y;
if (ShouldSpawnEnemies)
{
if (BoxInfo.IsInside(BoxOnWorld))
{
NewPawn = GetWorld()->SpawnActor<AAI_BasicEnemy>(EnemyClass, BoxOnWorld, RotatorBoxOnWorld);
FVector BoxOnWorld = GetActorLocation();
if (NewPawn != NULL)
{
if (NewPawn->Controller == NULL)
{
NewPawn->SpawnDefaultController();
}
if (BehaviorTree != NULL)
{
AAIController* AIController = Cast<AAIController>(NewPawn->Controller);
if (AIController != NULL)
{
AIController->RunBehaviorTree(BehaviorTree);
}
}
}
//.........这里部分代码省略.........