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"

Is there some way to find out if a vector world location is inside a collision box?

Basically what i'm wondering is if it's currently possible to find out if a vector location is inside one or more collision boxes that are placed in the world.

What i need this for is that when my AI hears certain noises i want to be able to check if the location of this sound is within a certain collision/overlap box.

I have been looking around a bit but i cannot seem to find anything that could be used for this. Any help is appreciated.

Product Version: UE 4.9
more ▼

asked Nov 26 '15 at 09:52 AM in Using UE4

avatar image

200 54 53 64

avatar image Slavq Aug 16 '16 at 03:58 PM

Any clues yet? :) The workaround I have on mind is to spawn actors for every location you want to check and then check if it's in 'IsOverlappingActor' on your box.

avatar image Solicio Aug 16 '16 at 05:43 PM

I think i have something similar to what you are thinking about, but i chose not to create new actors for each check as this would be very expensive for what i was going to use it on. I instead put the function on my Gamemode and created a USphereComponent on the Gamemode that i move around.

 bool AHomeInvasionGameMode::IsLocationOverlapping(FName Tag, FVector Location)
     if (OverlapSphere == nullptr)
         return false;
     // Move the sphere to the desired location that is going to be checked
     // Get all actors that are overlapping the sphere
     TArray<AActor*> OverlappingActors;
     // Loop through the array of actors and check the tags for the right one
     for (auto Itr(OverlappingActors.CreateConstIterator()); Itr; Itr++)
         if ((*Itr) != nullptr && (*Itr)->ActorHasTag(Tag))
             return true;
     // Move the component back to 0
     return false;

However i did also find functions that does things like this that can be used instead. https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/Engine/UWorld/OverlapAnyTestByChannel/index.html https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/Engine/UWorld/OverlapMultiByChannel/index.html

Hope this helps :)

avatar image Slavq Aug 16 '16 at 05:51 PM

Ah yes, moving an actor/component will be better than spawning every time. I guess that I'll implement something in this fashion too.


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

1 answer: sort voted first

The BoxCollision component has functions named IsOverlappingComponent and GetOverlappingComponents. If your sound generator Actor has a collision component, it could be used for testing if the box is overlapping it. Also, there are the same functions aimed for Actors, instead of components. IsOverlappingActor and GetOverlappingActors.

more ▼

answered Nov 26 '15 at 11:44 AM

avatar image

1.1k 28 39 90

avatar image Solicio Nov 26 '15 at 11:46 AM

I'm using the AI perception component for hearing, and as far as i know, there is no collision present at the sound location.

avatar image RVillani Nov 26 '15 at 11:53 AM

Somehow, you know the sound location, correct? What if you moved some dummy collision sphere to this location and used it's IsOverlappingXXX functions? I'm not very familiar with the AI system yet.

avatar image Solicio Nov 26 '15 at 11:54 AM

I was thinking of doing something like this but i thought i'd check if there was some way to avoid doing it like this.

avatar image RVillani Nov 26 '15 at 12:19 PM

Probably There's some math that checks if a vector is inside a box, but I believe it won't be simple in order to account for box rotations and it'd be very cumbersome to do in Blueprints. Unless you're willing to write it in C++. But I don't know the math... =(

(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