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"

How can you tell the engine which sprite collision shape to use when performing overlap checks?

I have a 2D sprite that has two collision shapes defined. In my code I am referencing the UPaperFlipbookComponent and performing overlap checks (using 3D physics) with something along these lines:

 AActor *AHeroPawn::CollideFirst(float x, float z) {
     AActor *res = NULL;
     FVector originalLocation = GetActorLocation();
     FVector newLocation = GetActorLocation();
     newLocation.X = x;
     newLocation.Z = z;
     TArray<AActor *> actors;
     Sprite->GetOverlappingActors(actors, NULL);
     for (auto CompIt = actors.CreateIterator(); CompIt; ++CompIt) {
         UE_LOG(LogTemp, Warning, TEXT("Overlapping actor."));
         AActor *OverlappingActor = *CompIt;
         if (OverlappingActor != this) {
             UE_LOG(LogTemp, Warning, TEXT("Actor: %s"), *AActor::GetDebugName(OverlappingActor));
             res = OverlappingActor;
     return res;

This is working fine as long as I have just one collision shape. The moment I have two shapes (i.e. one for world collision and one as enemy hitbox) it looks like GetOverlappingActors is using either all the shapes or the biggest or just the first as my first one is the biggest.

I'd rather have it perform overlap checks using the collision shape I tell it to. Is there any way to accomplish this?

Another way could be to enumerate the collision shapes and be able to enable/disable them before performing the overlap check, but I couldn't find a method to get the list of the collision shapes.

Thanks in advance for any help!

Product Version: UE 4.14
more ▼

asked Jan 28 '17 at 11:26 AM in Using UE4

avatar image

49 6 9 13

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

1 answer: sort voted first

I'm answering my own question. The easiest way is to avoid using the sprite collision shapes at all and attach as many UBoxComponent to the Actor as needed. In my case I created two UBoxComponent, one for world collisions and one for bullets collisions. That way I can just call GetOverlappingActors() on the component I want to check with.

more ▼

answered Jan 30 '17 at 06:45 PM

avatar image

49 6 9 13

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
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