UBoxComponent which is child of pawn not firing overlap events

I have a UBox Component that is a child of a Pawn. I move the UBoxComponent around independent of the pawn and it doesn’t seem to generate hit events. I have done “show collision” and the collision components are overlapping. Here is the code I have for setting up the collision. (I have added more that I thought I needed in hopes it would fix the issue). I have checked the other objects I need to collide with and they all have bGenerateOverlap set to true.

		static FName HandCollsionProfileName(TEXT("OverlapAllDynamic"));
		CollisionComponent->SetCollisionProfileName(HandCollsionProfileName);
		CollisionComponent->SetSimulatePhysics(false);
		CollisionComponent->bGenerateOverlapEvents = true;
		CollisionComponent->bMultiBodyOverlap = true;
		CollisionComponent->bTraceComplexOnMove = true;

		CollisionComponent->OnComponentBeginOverlap.AddDynamic(this, (Hand == EHand::Left ? &AVRPawn::OnCollisionLeftHand : &AVRPawn::OnCollisionRightHand));

Anyone got any suggestions? I keep trying different things and nothing is working. :frowning:

Hey -

It looks like you are trying to bind one of two functions based on “Hand” correct? Does the argument list of your OnCollisionLeft/RightHand functions match the argument list for OnComponentBeginOverlap? If you remove the ternary operator and only bind one function, does that function trigger when the box is overlapped?

Cheers

Hey ! Thanks for the help.

When you made your suggestion I immediately thought, "Well that wouldn’t be an issue unless ‘AddDynamic’ is a macro " so I dismissed it. Then I took a look at the function to see what was wrong and sure enough it IS a #define macro.

I thought the standard in UE4 source was to use all CAPS for Macro definitions. Am I wrong? It seems pretty confusing to do things this was as event the Delegate.h file has macros in all caps and macros not in caps.

Hey -

To answer your question, we generally do use caps for macros. AddDynamic is a special “pseudo-member function” so it is made to look like one. The easiest solution would be to create a Dummy function to bind to your box component and have that function check the value of Hand and call either of the other two functions appropriately.

Cheers