x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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.

Product Version: UE 4.9
Tags:
more ▼

asked Oct 14 '15 at 05:24 PM in C++ Programming

avatar image

Zelos64
6 3 5 8

avatar image Matthew J ♦♦ STAFF Oct 16 '15 at 03:26 PM

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 APainCausingVolume. You can look at the .h and .cpp files for further information on its functions/implementations.

avatar image Zelos64 Oct 16 '15 at 04:49 PM

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.

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

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:

https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/GameFramework/AActor/ReceiveAnyDamage/index.html

Hope this helps!

more ▼

answered Oct 20 '15 at 08:21 PM

avatar image

Matthew J ♦♦ STAFF
31.8k 526 91 417

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question