x

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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

OverlapMulti producing error

I'm trying to use OverlapMulti to generate an array of hits, then use a for loop to build an array of the actors from those hits (so I can use the editor to visually verify that the correct objects are being detected and returned). However, this is producing a boatload of errors:

error C2440: '=' : cannot convert from 'TWeakObjectPtr' to 'AActor *'

error C2653: 'overlaps' : is not a class or namespace name

error C3861: 'Num': identifier not found

The first error, in particular, is what really has me confused- I thought I was comparing a pointer to a pointer, so there shouldn't be any problems.

CharacterPerception.h:

 public:    
     // Sets default values for this component's properties
     UCharacterPerception();

     void SenseStuff();
 
     UPROPERTY(VisibleAnywhere)
     AActor* myActor;
     UPROPERTY(VisibleAnywhere)
     TArray<FOverlapResult> overlaps;
 
     UPROPERTY(VisibleAnywhere)
     TArray<AActor> actorArray;
     // Called when the game starts
     virtual void BeginPlay() override;
     
     // Called every frame
     virtual void TickComponent( float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction ) override;
 };



And the relevant function from CharacterPerception.cpp:

 void UCharacterPerception::SenseStuff()
 {
     //TArray<FOverlapResult> overlaps;
     AActor* Origin = this->GetOwner();
     float Radius = 150.0f;
 
     if (Origin->GetWorld()->OverlapMulti(
         //output list
         overlaps,
         //origin location
         Origin->GetActorLocation(),
         //origin rotation
         FQuat::Identity,
         //collision channel
         ECollisionChannel::ECC_Pawn,
         //collision primitive
         FCollisionShape::MakeSphere(Radius),
         //collision parameters
         FCollisionQueryParams()))
     {
 
         for (int i = 0; i < overlaps::Num();){
             actorArray[i] = overlaps[i].Actor;
         }
 
         GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Red, "I see you!");
     }
 }
Product Version: UE 4.8
Tags:
more ▼

asked Jun 18 '15 at 02:57 PM in C++ Programming

avatar image

HInoue
251 95 66 83

(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