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"

How can I check if something is STILL WITHIN a trigger volume?

I know about "Begin Overlap" and "End Overlap".....but what I REALLY need is to know if something is STILL within the bounds of the trigger volume after it's already been overlapped.

Product Version: UE 4.7
Tags:
more ▼

asked Jun 25 '15 at 08:47 PM in Blueprint Scripting

avatar image

VagrantProfile
101 19 27 36

avatar image ivanrosadev Sep 16 '15 at 12:09 AM

It's a shame that a so called "NEXT-GENERATION" engine like Unreal Engine 4 doesn't have something that even Gold Source do. But hey, we have PBR -.-

And yes, I know about get overlapping actors. Is not the same.

(comments are locked)
10|2000 characters needed characters left

10 answers: sort voted first

Actors and Primitive Components have GetOverlappingActors to check for other actors that are overlapping your actor:C++ doc and Blueprint node.

So you want something like TriggerVolume.GetOverlappingActors().Find(this) >= 0 (or the blueprint equivalent).

more ▼

answered Feb 19 '16 at 01:55 AM

avatar image

idbrii
492 5 15 43

(comments are locked)
10|2000 characters needed characters left

I was having a similar problem because I was spawning characters within the trigger, and needed to know if anything was overlapping it or not.

I figured out a pretty simple solution to my problem at least:

  • Set up an Int value 0

  • OnActorBeginOverlap add 1 to it

  • OnActorEndOverlap subtract 1 from it

If the int == 0, you know there is nothing overlapping the trigger

more ▼

answered Feb 26 '18 at 11:06 PM

avatar image

iKnewt
51 5 4

avatar image Starkium Oct 26 '18 at 01:57 AM

alt text

yup I would do it like this as well. In this situation of something spawning in the volume do a check at spawn to manually set variables. In my situation I have players spawn inside a volume like so and I will tell the volume how many players have entered. You should also make sure that these variables are capped to never go past your max number of players and never go below 0.

This volume also triggers other spawning actors for zombies which I toggle active or inactive based on these variables. I use dungeon architect to procedurally spawn cities with also procedurally place zombie spawners. At level load I could do an initial sweep to check for spawners or I could do that way before while the player is loading in and keep track of all the assignments in a save file.

The reason this is difficult is because it's blueprint. Blueprint is supposed to be like this because it forces to learn C++ which is for the most part better for everything. Don't get mad, go learn :)

contains.png (124.1 kB)
(comments are locked)
10|2000 characters needed characters left

I would make an array: add an object on "Begin Overlap" and subtract the same object on "End Overlap". This will give you an array of objects overlapping the volume.

more ▼

answered Jun 25 '15 at 08:52 PM

avatar image

gloim
159 3 9 21

avatar image idbrii Feb 19 '16 at 01:55 AM

The trigger volume already keeps such a list: GetOverlappingActors.

avatar image rent treznor Jan 23 '19 at 07:53 PM

Not if the object is spawned inside it.

(comments are locked)
10|2000 characters needed characters left

You could just use a variable with the begin overlap and end overlap functions. alt text

overlap.png (51.7 kB)
more ▼

answered Jun 25 '15 at 08:54 PM

avatar image

Tan2684
61 4 8 13

avatar image DanzigLucifuge May 18 '17 at 11:18 PM

This answer is completely useless! better luck next time guy

avatar image wisemethuselah Jun 19 '17 at 08:42 PM

This is not a useless method, it is the correct one. This can be used to check if something is still inside a trigger. The BeginOverlap only fires once when it happens, so it will happen once and set overlapped to true. Now if you ever want to check if the actor is within the volume you check if overlapped is true using whatever other methods you need whenever you need. All the time the actor is inside the trigger overlapped will be true. Only if the actor leaves the trigger it sets overlapped to false. All you need here is the check for the specific actor so not everything triggers it.

avatar image Xanadron Jul 11 '17 at 10:58 AM

Setting up a bool upon beginning and ending an overlap is the correct, simple and recommended way to do it. Better luck next time kid.

avatar image Lexeon Sep 01 '17 at 07:35 AM

However, this does not account for situations where the object is spawned within the trigger.

avatar image navid100 Feb 27 '18 at 08:04 AM

This answer IS useless. Consider I have two objects. First object enters the volume so the 'Overlapped' variable sets to true. Then the second object enters the volume (the variable will remain true). Now if one of the objects leave the volume, the 'Overlapped' variable sets to false while I still have an object inside. This answer only works if you can guarantee that only one object can be inside the volume at a time.

By the way, As so many have answered this question I would like to add another way to achieve this. You also can use a 'multi box trace for objects' node and set the start and end at the center of the trigger volume (with slightly changed the end vector) and set the half size to fit the volume. it will output an array of all objects that you have set and also can ignore specific types of actors.

Regards,

(comments are locked)
10|2000 characters needed characters left

You can get voulme BSP information and check manually against the point, but it is possible only in C++ as I know.

 bool AMyVolume::IsPositionInside(const FVector& Position) const
 {
     bool bFallback = false;
 
 #if WITH_EDITOR
     if (ABrush::NeedsRebuild())
     {
         // Fallback to the collision tests when there is no valid model
         UE_LOG(WaterMeshRuntime, Log, TEXT("Level BSP needs to rebuild."));
         bFallback = true;
     }
 #endif
 
     if (Brush == nullptr) {
         // Fallback to the collision tests when there is no valid model
         bFallback = true;
     }
 
     if (bFallback) {
         UWorld* CurrentWorld = GetWorld();
         return CurrentWorld ? CurrentWorld->OverlapAnyTestByChannel(Position, FQuat::Identity, ECollisionChannel::ECC_OverlapAll_Deprecated, FCollisionShape::MakeSphere(0.01f)) : false;
     }
 
     // Use volume bsp here
 
     int32 nodeIx = 0;
     const FBspNode* node = Brush->Nodes.GetData();
     const FVector InnerPosition = GetTransform().InverseTransformPosition(Position);
 
     while (node != nullptr)
     {
         // Check if point is in front of plane
         if (node->Plane.PlaneDot(InnerPosition) > 0.0f)
         {
             // FRONT
             if (node->iFront != INDEX_NONE)
             {
                 node = &Brush->Nodes[node->iFront];
             } else {
                 return !node->ChildOutside(1, Brush->RootOutside);
             }
         } else {
             // BACK
             if (node->iBack != INDEX_NONE) // If there is a child, recurse into it.
             {
                 node = &Brush->Nodes[node->iBack];
             } else {
                 return !node->ChildOutside(0, Brush->RootOutside);
             }
         }
     }
 
     return !Brush->RootOutside;
 }
 

works fine.

more ▼

answered May 19 '17 at 02:29 AM

avatar image

c4tnt
1k 12 8 29

(comments are locked)
10|2000 characters needed characters left

This is an alternative solution that may or may not be better for you, based on the situation you are dealing with, but the engine does have shape traces where you sweep through a particular area of space and the trace informs you of whether you have hit a specific type of object within that space. Running this every tick would be much more costly than the "use a variable/array on begin/end overlap" suggestions.

https://docs.unrealengine.com/latest/INT/Gameplay/HowTo/UseRaycasts/Blueprints/index.html#shapetraces

more ▼

answered Jun 25 '15 at 09:42 PM

avatar image

Envisioner
184 9 17 23

(comments are locked)
10|2000 characters needed characters left

You may add a flipflop to toggle between states. Whenever an exec signal occurs, the flipflop change (and hold) state. In the following schematic, the system prints true or false to determine overlapping states alt text

more ▼

answered Mar 11 '16 at 12:39 PM

avatar image

GPalamas
1 1

(comments are locked)
10|2000 characters needed characters left

Hey. I was facing same problem and came out with something like this. You can add a delay between "Then 1" in Sequencer and Branch, so that loop leave some space for other actions. I don't know how it will work in longrun, since I'm pretty new in UE4.

alt text

screen.jpg (103.9 kB)
more ▼

answered Feb 19 '17 at 09:21 AM

avatar image

RushingVice
8 1 2 6

(comments are locked)
10|2000 characters needed characters left

PhysicsVolume and ActorEnteredVolume(class AActor* Other), ActorLeavingVolume(class AActor* Other) is what you were looking for.

more ▼

answered Apr 12 '17 at 09:26 AM

avatar image

Krzysiek_TATE
209 4 12 18

avatar image bathorysthroat Apr 29 '17 at 08:41 AM

Could use explain how to do this in Blueprint form?

(comments are locked)
10|2000 characters needed characters left

This should do it. Basically it takes an actor (your pawn perhaps) and tests to see if the actor location is within the box bounds of a container like a triggerbox or a collision box or whatever you choose. This only tests for a single vector of the actors location within the container and does not test beyond that. If you need full collision testing, repeat the same code for the Actor that you see for the Container and test bounds within bounds or write a recursive function to test multiple vectors within the container bounds.

This assumes the input objects inherit from the Actor class. alt text

more ▼

answered Jan 23 '19 at 07:34 PM

avatar image

rent treznor
26 1 4

avatar image JonathanJobin 2 days ago

I was looking for something similar and tried rent treznor's solution and maybe I'm missing something but it didn't work right for me. Played around for a bit and came up with this solution so I thought I'd post it here if anyone is interested:

alt text

capture.png (176.1 kB)
(comments are locked)
10|2000 characters needed characters left
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