I have two classes that serve as base classes for various enemy and projectiles in my 2D game.The Problem is that they don’t collide with each other at all and I get the warning that “Body is set to simulate physics but Collision enabled is incompatible”. In both cases the root component is a UPaperSpriteComponent. My code is as follows and is essentially the same for both classes. I can verify in the editor that when the game is running, that the properties are set to the proper values.
AMob::AMob()
{
// Set this pawn to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
this->sprite = CreateDefaultSubobject<UPaperSpriteComponent>(TEXT("Sprite"));
this->sprite->AttachTo(this->RootComponent);
this->RootComponent = this->sprite;
this->OnActorBeginOverlap.AddDynamic(this, &AMob::collisionHandler);
this->OnActorEndOverlap.AddDynamic(this, &AMob::collisionDummy);
}
// Called when the game starts or when spawned
void AMob::BeginPlay()
{
Super::BeginPlay();
this->alive = true;
this->sprite->SetSimulatePhysics(true);
this->sprite->SetEnableGravity(false);
this->sprite->SetCollisionEnabled(ECollisionEnabled::PhysicsOnly);
this->sprite->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Overlap);
}