[C++] Making a custom colliding pawn

I’m struggling to find any information on how to make a custom pawn collidable.
As far as I’ve understood, the easiest way of making pawn colliding with other actors( i.e. walking on ladders, or getting blocked by walls) is to use OnActorBeginOverlap, so do I.
I’ve created a basic function to check if colliding is detected at all, it creates a sphere when collision with other actor happened.

void ACustomProtogonist::OnOverlapBegin(class AActor* OtherActor)
{ 
	if (OtherActor && (OtherActor != this))
	{
		//Spawn a new component  
		UStaticMeshComponent* VisualComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("VisualComponent")); 
		static ConstructorHelpers::FObjectFinder<UStaticMesh> VisualComponentAsset(TEXT("/Game/StarterContent/Shapes/Shape_Sphere.Shape_Sphere"));
		if (VisualComponentAsset.Succeeded())
		{
			VisualComponent->SetStaticMesh(VisualComponentAsset.Object);
			VisualComponent->SetRelativeLocation(FVector(0.0f, 0.0f, -90.0f));
			VisualComponent->SetWorldScale3D(FVector(0.7f));
		}
	}
}

Unfortunately it doesn’t work. I can’t figure out if it collides at all. I’ve used

this->OnActorBeginOverlap.AddDynamic(this, &ACustomProtogonist::OnOverlapBegin);
 SetActorEnableCollision(true);

beforehand.

Honestly, if you want collision it will be way easier to just make a blueprint that inherits from your C++ class. Rolling your own will just give you headaches in the long run. It is trivially easy to handle this with blueprints, and doesn’t really have much more overhead than using just a C++ class, and you’ll save that overhead by not having a convoluted way of dealing with collision.

If you are dead set on doing it yourself, you’ll need to enable collision on your actor, attach a collider to your actor, and assign that collider some collision properties using SetCollisionEnabled or SetResponse. I can not recommend avoiding this enough though.

Thanks, Sir. The hardest part for me right now is to understand where C++ should be used and where it shouldn’t. Mostly people say C++ isn’t needed right now at all.

Yea, it can be tricky. My rule of thumb is in general anything that you see in the game should have a blueprint. If you want to implement it in C++, then make it a blueprint that inherits from a custom C++ class. If it’s not actually visible in the game, you kind of have to guess. If the class leans heavily on engine functionality over your own implementation, I’d probably make a blueprint for it though.

On our project we tend to do a lot of Blueprint inheriting from a C++ base class to keep as much functionality as possible in C++. That’s mostly just for consistency. I think if I were starting fresh I’d probably try 100% blueprints and only do C++ implementation when there were either performance or functionality reasons to. It’s always easy to convert blueprint to C++ later because they’re almost 1:1 as far as general flow goes.