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"

AoE Damage

I'm trying to figure out how to do Area of Effect damage with blueprints. I want to make it so say, if a character is standing on a type of floor or is inside a certain collision sphere their health will gradually go down. I've tried to have a while loop but the health just depletes in an instant, and putting a delay inside a while look just causes an infinite loop for some reason. I just want it to take a bit of health away gradually for as long as the player is in the AoE

Product Version: UE 4.10
Tags:
more ▼

asked Jun 21 '16 at 04:04 PM in Blueprint Scripting

avatar image

TheBlackRanger
10 1 4 4

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

When the actor steps on the tile, or enters the sphere, you could create a looped timer using Set Timer by Function Name. So, for example, every 5 seconds you could apply damage.

Keep a reference to the timer handler (return value from the node). You'll want to cancel it the moment they leave the hazard.


Example of handling this via a timer. This has a bug (you'd want to call EndAOE on player death)

alt text

more ▼

answered Jun 21 '16 at 04:13 PM

avatar image

FrostedSentry
396 16 8 16

avatar image TheBlackRanger Jun 21 '16 at 05:04 PM

alt text

this is what I have so far, not sure what else I's need to change

avatar image FrostedSentry Jun 21 '16 at 05:16 PM

Is "Do Dam" a function you have somewhere else? I think you meant to use "Set Timer by Event"

avatar image TheBlackRanger Jun 21 '16 at 05:23 PM

no, i just dont really know what im doing here

avatar image TheBlackRanger Jun 21 '16 at 05:27 PM

alt text

Alright, changed it again, can you tell me what the issue is with this one?

avatar image FrostedSentry Jun 21 '16 at 05:41 PM

Added an example that you can review! Hope it helps!

avatar image TheBlackRanger Jun 21 '16 at 06:08 PM

Doesnt seem to work with the code I already have, but thanks anyway, I'm not sure how to use your example, with the begin overlap, I have in the pictures I showed

avatar image TheBlackRanger Jun 21 '16 at 06:12 PM

It just causes the player to die instantly

avatar image TheBlackRanger Jun 21 '16 at 06:16 PM

this is was my attempt at integrating your codealt text

avatar image FrostedSentry Jun 21 '16 at 06:34 PM

In this case you trigger the dead state if it's >. You may also want to add a 0 to the "Compare With" pin for clarity.

avatar image TheBlackRanger Jun 21 '16 at 06:38 PM

unfortunately it still doesn't work, the character doesn't die anymore, but the health doesn't go down over time, it still only goes down once, when the player enters the sphere, but doesn't repeat the process every few seconds, it just happens every time the player enters the sphere again

avatar image FrostedSentry Jun 21 '16 at 06:40 PM

Few seconds? Perhaps the 15 second loop time is the issue. Maybe reduce that a bit more. :)

avatar image TheBlackRanger Jun 21 '16 at 06:46 PM

I did, I reduced it to one second, still nothing

avatar image FrostedSentry Jun 21 '16 at 06:56 PM

Let's clean these events up a bit

  • OnComponentBeginOverlap > Save a reference to the Actor to a variable > Fire BeginAOE

  • BeginAOE > Set Timer By Event > Store Timer Handler > Get Actor Reference > Subtract Damage > Call DidDamage

  • DidDamage > Compare Value of Health > If less-than 0 > Die > Call EndAOE

Don't worry about getting variables or creating more nodes. Clarity is important. Somehow I don't think those nodes are being "shared" properly.

avatar image TheBlackRanger Jun 21 '16 at 06:54 PM

Okay, I changed the amount of damage and it does look like its working but on a very small scale, for some reason it takes a bigh chunk of damage when the player first enters the sphere and then very very small amounts after staying in it, any idea why it take so much when it first enters?

avatar image FrostedSentry Jun 21 '16 at 06:57 PM

Perhaps it's getting called multiple times? Try using print string to verify when that's getting called.

avatar image TheBlackRanger Jun 21 '16 at 07:00 PM

yea, looks like it, not really sure why its doing that though

avatar image FrostedSentry Jun 21 '16 at 07:09 PM

Double check your collision meshes. Alternatively, you could maintain a bool "PendingDamage" that could be checked & cleared on damage.

avatar image TheBlackRanger Jun 21 '16 at 07:31 PM

alright, ill try that, thanks for all the help

avatar image TheBlackRanger Jun 21 '16 at 07:35 PM

think its all working now, thanks again

avatar image FrostedSentry Jun 21 '16 at 07:40 PM

Happy to help. Best of luck on the journey and The White Ranger FTW! :P

avatar image FrostedSentry Jun 21 '16 at 06:38 PM

I would also avoid just dragging a pin from the Set Health node & just use Get Health for DidDamage->CompareFloat's input.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
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