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++?