TakeDamage() doesn't work

I have overriden the TakeDamage()-Function inside a class which is deriving from the StaticMeshActor. But for some reason it doesn’t get triggered when a nearby radial damage fires.


 virtual float TakeDamage(float DamageAmount, struct FDamageEvent const& DamageEvent, class AController* EventInstigator, class AActor* DamageCauser) override;


float ASomPickup::TakeDamage(float DamageAmount, struct FDamageEvent const& DamageEvent, class AController* EventInstigator, class AActor* DamageCauser)
	float ReturnValue = Super::TakeDamage(DamageAmount, DamageEvent, EventInstigator, DamageCauser);

	print("Take Damage: " + FString::SanitizeFloat(DamageAmount));

	return ReturnValue;

what am I doing wrong?

Hello Braindrain85,

I’ve never directly used TakeDamage myself but I don’t believe that it is a delegate like the various Overlap or Hit events in the editor. You would need to set up a delegate of your own or bind the function call to an existing delegate to get this function to be called when you take damage.

TakeDamage is meant to handle the damage being taken, as Apply Damage would in blueprints for Destructible components.

You can find more information about delegates here: Delegates | Unreal Engine Documentation

Hope this helps!

Thanks for your answer, Matthew.

My override-Method actually works now. I have made a mistake.

I did set the CollisionObjectType of the damage receiving object to “world static” instead of “world dynamic” and inside Blueprints the “Damage Prevention Channel” of the “Apply Radial Damage”-Node was set to “World Static”…
so the object prevented itself from receiving damage :-/

Hey there! Can you tell me where you found this “Apply radial Damage” Node in the blueprint?

Just right click inside the graph section of the blueprint and type “Apply radial damage”

ohhh… thanks! i was looking at it wrong… I was trying to do the same with C++. I thought you are talking about something in the details tab…lol… pretty stupid of me.
However, I did the same with C++ and I still don’t find it damaging one of the actors. Specifically, an actor whose object type I set to either World Dynamic or Vehicle or a custom one which has trace response of visibility set to block. However, overlapping with it works when I check the log. Any suggestions?

Here is portion of my constructor code for the actor which uses TakeDamage. Maybe you need to set the “bCanBeDamaged” Variable to true?..

if (EnvironmentMesh)

	//RootComponent = GetStaticMeshComponent();

	//Prevent Scaling with character bones
	GetStaticMeshComponent()->bAbsoluteScale = true;

	//Make the vicinity volume of the character recognize the pickups
	GetStaticMeshComponent()->bGenerateOverlapEvents = true;

	//Set mobilty to moveable (for recognitions sake)

	//Make the Static Mesh dynamic

	//Turn on physics for the static mesh

	//Turn on generating hit events for this Comp

	//Use Complex collision
	GetStaticMeshComponent()->GetBodyInstance()->bUseCCD = true;

	//Turn on Replication for static mesh component


	//Enable damage if needed
	if (bPickupCanBeDamaged)
		bCanBeDamaged = true;
	//Ignore Camera Collision
	GetStaticMeshComponent()->SetCollisionResponseToChannel(ECollisionChannel::ECC_Camera, ECollisionResponse::ECR_Ignore);

“bCanBeDamaged” is set to true in the BP version of the C++ class object. I can try it out in C++, but I doubt whether the BP will be overridden as the BP constructor runs after the C++ constructor.