Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

moveto behaviortree c++ not work

Hello everyove i have strange problem but I do not understand what is wrong. I want be char move to player

aicontroller class

 #include "MyProject.h"
 #include "MyAIController.h"
 #include "AssentilalChar.h"
 AMyAIController::AMyAIController(const class FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
     BehaviorComp = ObjectInitializer.CreateDefaultSubobject<UBehaviorTreeComponent>(this, TEXT("BehaviorComp"));
     BlackboardComp = ObjectInitializer.CreateDefaultSubobject<UBlackboardComponent>(this, TEXT("BlackboardComp"));
 void AMyAIController::Possess(class APawn* InPawn)
     AAssentilalChar* MyChar = Cast<AAssentilalChar>(InPawn);
     TArray<AActor*> ActorsArray;
     UGameplayStatics::GetAllActorsOfClass(GetWorld(), AAssentilalChar::StaticClass(), ActorsArray);
     AAssentilalChar* player = Cast<AAssentilalChar>(ActorsArray[0]);
     BlackboardComp->SetValueAsObject("Target", MyChar);


Char Class:

 #include "MyProject.h"
 #include "Engine.h"
 #include "MyProjectProjectile.h"
 #include "MyProjectCharacter.h"
 #include "AssentilalChar.h"
 // Sets default values
      // Set this character to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
     PrimaryActorTick.bCanEverTick = true;
     SphereComponent = CreateDefaultSubobject<USphereComponent>(TEXT("sphere"));
     RootComponent = SphereComponent;
     UStaticMeshComponent* SphereVisual = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("VisualRepresentation"));
     static ConstructorHelpers::FObjectFinder<UStaticMesh> SphereVisualAsset(TEXT("/Game/StarterContent/Shapes/Shape_Sphere.Shape_Sphere"));
     if (SphereVisualAsset.Succeeded())
         SphereVisual->SetRelativeLocation(FVector(0.0f, 0.0f, -40.0f));
 // Called when the game starts or when spawned
 void AAssentilalChar::BeginPlay()
 // Called every frame
 void AAssentilalChar::Tick( float DeltaTime )
     Aitest = Cast<AAIController>(GetController());
     GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("This is an on screen message!"));
     TArray<AActor*>  SpawnedBullet;
     UGameplayStatics::GetAllActorsOfClass(GetWorld(), AMyProjectCharacter::StaticClass(), SpawnedBullet);
     EPathFollowingRequestResult::Type MoveToActorResult = Aitest->MoveToActor(SpawnedBullet[0]);
     Super::Tick( DeltaTime );
 // Called to bind functionality to input
 void AAssentilalChar::SetupPlayerInputComponent(class UInputComponent* InputComponent)

I create BP from cpp class and add my aicontroller and my behavior tree but my char DONT move!!! whats wrong?

alt text

Product Version: UE 4.12
more ▼

asked Aug 15 '16 at 10:37 PM in C++ Programming

avatar image

1 1

avatar image MieszkoZ STAFF Aug 20 '16 at 12:04 AM

What does the Visual Log say?



avatar image vadiknsk Aug 20 '16 at 05:28 AM

Compile without error

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question