problems with UCapsuleComponent overlapping

Hi all,

I have a custom class which has a UCapsuleComponent attached. Upon calling a function (not constantly), I want to test to see if this component is overlapping either partially or fully with any other collidable object (ECC_PhysicsBody). How would I go about doing this?

I’ve already tried the following code, but it never returns any results:



		TestCapsule->SetWorldLocation(TestLocation);
		TestCapsule->SetCapsuleSize(iCapsuleHalfWidth, iCapsuleHalfHeight, true);

		TestCapsule->bGenerateOverlapEvents = true;
		TestCapsule->bMultiBodyOverlap = true;
		TestCapsule->bTraceComplexOnMove = true; //yes, i'm trying everything i can think of

		TArray<AActor*> Overlaps;
		TestCapsule->UpdateOverlaps();
		TestCapsule->GetOverlappingActors(Overlaps);
		if (Overlaps.Num() == 0)
		{
			UE_LOG(HelloWorld, Log, TEXT("no overlaps"));
			bPointIsGood = true;
		}
		else
		{
			UE_LOG(HelloWorld, Log, TEXT("overlapping %i objects"), Overlaps.Num());
			bPointIsGood = false;
		}


You should get an OnComponentBeginOverlap call when the capsule overlaps something shouldn’t you? Did you add method handlers for those?

Of course the Capsule needs to have collision enabled too, that would be my first port of call. Also Zoombapup is right in that there are already a bunch of delegates used to trigger collision events that you just need to tap into.

So I’ll need to add my own capsule class in order to override OnComponentBeginOverlap, correct?
If the Overlaps array never gets populated, why does it exist?

edit: I must be doing my binding wrong, it never fires.
I’m declaring it like so:



// .h
TScriptDelegate<FWeakObjectPtr> capdelegate;

//.cpp
capdelegate.BindUFunction(this, TEXT("testFunc"));
TestCapsule->OnComponentBeginOverlap.Add(capdelegate);


according to the docs, bGenerateOverlapEvents needs to be set to true for every single object i want to test against. i’ve set this temporarily for my test objects, but still no events are generated. i’m declaring the delegate as the last part in the constructor.

edit 2: the capsule is moving and testing overlap multiple times in a single frame, could this be part of the issue?