How to use Pain Causing Volume to damage player

I want to use the pre-made Pain Causing Volumes to damage the player instead of making something similar with code. I’m new to coding with UE4, but I’m sure it’s something simple.

Hello Zelos64,

I’m not quite sure I understand what you mean. You mention wanting to use the pre-made pain causing volumes instead of making something with code, but it seems like you do want to use code? Are you looking to use default pain causing volumes inside of C++ itself? If this is the case, their class name in code is . You can look at the .h and .cpp files for further information on its functions/implementations.

I want to use code, but I don’t want code a custom volume. I want to implement the Pain Causing Volumes to interact with the player using the ones already in the engine. I just need to know how to code it where I can put the volumes anywhere and adjust each one differently, and they’ll all still affect the player. Basically what I’m asking is how to make the Pain Causing Volume to affect my Health variable.

The easiest way to do this would be to use the ReceiveAnyDamage function from the AActor class on your character. This function is called whenever any type of “damage” is dealt to your character. Whenever you step into a Pain Causing Volume, it causes “damage” to your player for the amount that you have set and for the damage type set. If you step into a Pain Causing Volume, any code that you’ve put into your overridden ReceiveAnyDamage function will be called, which you can use to decrease your health by the value that is passed into the function by the Pain Causing Volume. You can find more about this function’s declaration here:

Hope this helps!