Download

ActorBeginOverlap

I’m trying to get collision set up within my game for when the enemy overlaps the player they take damage.

I’ve got it setup so far that the Player can take damage when entering the ‘Collision Box’ of the enemy via blueprint. The Player uses the TakeDamage function in C++ and works with no issues.
I’ve got the Event ActorBeginOverlap node connected to the ApplyDamage node which works perfectly.
I’m now trying to translate this into C++ rather then BP.

So far, I have this in the Actor that will be dealing the damage to the player.
BasicZombie.h

UPROPERTY(VisibleAnywhere, Category = BoxCollision)
     UBoxComponent* BoxCollider;

BasicZombie.cpp

ABasicZombie::ABasicZombie()
{
    BoxCollider = CreateDefaulySubobject<UBoxComponent>(TEXT("BoxCollider");
    BoxCollider->GetScaledBoxExtent();
    BoxCollider->SetupAttachment(RootComponent);
}

I have been searching around and a few different websites have said to use either OnActorBeginOverlap or OnComponentBeginOverlap and then use the AddDynamic function. However, the AddDynamic() function doesn’t exist only Add or AddUnique. Is there a new way of doing this in C++?

just write the AddDynamic even if it says it doesn’t exist.

I have done, but I get errors relating to macros I believe (not currently at my computer).

Show us the code that produces the error.

Added a screenshot of the error.

The Add Dynamic part is fine; the problem is with the parameter you are passing at &AMainCharacter::OnActorOverlap. You will want to pass &ABasicZombie::SomeFunction and make sure SomeFunction has the parameters that OnComponentBeginOverlap expects. Here’s an example. Add a delegate to OnComponentBeginOverlap in C++ - UE4 AnswerHub