I created a couple of enemies based off a custom class derived from ACharacter. I go into the blueprint and set the mesh and capsule components to BlockAll but as soon as I spawn it the capsule is changed to WorldStatic and doesn’t generate hit events when colliding with other actors in the world.
I tried adding code to BeginPlay to find the capsulecomponent but that returns a null so I do a loop over all mesh components and set all to BlockAll but I guess it must not find the capsule still since I still end up with WorldStatic after BeginPlay.
Why does this capsule auto change itself and how can I change it if I can’t find the capsule?
TArray<UStaticMeshComponent*> meshes; GetComponents<UStaticMeshComponent>(meshes);
for (UStaticMeshComponent* mesh : meshes)
{
mesh->SetCollisionProfileName(TEXT("BlockAll"));
}
UCapsuleComponent* capsule = GetComponentByClass< UCapsuleComponent>();
if (capsule)
{
capsule->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Block);
}
else
UE_LOG(LogTemp, Error, TEXT("Could not find the capsule component on this character"));