Hi…
Collision for actor components are not being generated in my code for some reason.
.h file
UPROPERTY(VisibleDefaultsOnly, Category = Collison)
TSubobjectPtr CollisionComp;
void OnOverlap(AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);
.cpp file
ATeleporter::ATeleporter(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
CollisionComp = PCIP.CreateDefaultSubobject<UCapsuleComponent>(this, TEXT("CapsuleComp"));
CollisionComp->InitCapsuleSize(90, 170);
CollisionComp->BodyInstance.SetCollisionProfileName("OverlapAll");
CollisionComp->OnComponentBeginOverlap.AddDynamic(this, &ATeleporter::OnOverlap); // set up a notification for when this component hits something
//CollisionComp->OnComponentHit.AddDynamic(this, &ATeleporter::OnHit);
RootComponent = CollisionComp;
}
void ATeleporter::OnOverlap(AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex)
{
GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Red, TEXT("Overlap"));
}
I have attached another static mesh component to this actor through blueprints. It is a physicbody having blockallcollison. The Static mesh component is responsible for physics simulation while the capsule component detects if a character stands on it.
Capsule Component BP
Staticmesh BP