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 can a turret get damage when being hit by an enemy on contact?

My enemies go from point A to point B(using a target pont). I want to place a turret in their path, so they can destroy it by giving the turret damage, but I can't seem to make it work, can you help me?alt text

(Sorry for the Spanish, English isn't my first language. Here are the translation of the words:

Proyectar = Cast, Aplicar daño = Apply damage, Rama = Branch)

Product Version: UE 4.20
Tags:
sin-titulo.png (114.3 kB)
more ▼

asked Aug 22 '18 at 07:07 PM in Blueprint Scripting

avatar image

ElectricTF
1 1 2

avatar image w0hoho Aug 22 '18 at 09:10 PM

who is attacking whom in this blueprint? What is NewBlueprint4 and where is this custom event and where do you call it?

Can you give more details?

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

1 answer: sort voted first

are you looking for the enemies to do damage over time or just a single hit per turret on impact?

if you want a single impact then i would just use a on begin overlap instead of the custom event you have now, then do the cast like your doing now or if your going to have many things the enemies can damage then have a system that uses tags, and last have the apply damage. i would have the turrets health check and destruction script in the turret blueprint.

if you want a damage over time (DOT) then you can do the same as above but add a timer in. so you would have the begin overlap -> set timer event -> then cast and the rest. then you set the timer to looping and the interval would be how often damage is applied. theres a bit more to this setup and ill try to add a picture in a few mins.

Edit: added pictures.

as you can see in the first picture which is the enemy on begin overlap you start a timer which fires a custom event every one second. this event damage turret first makes sure the turret still exists and if it does it applies damage, if the turret doesnt exist then the timer get stopped. the timer is also stopped when there is no more overlap (end overlap) so that if the enemy moves away or is not in the vicinity of the turret the damage stops.

of course all of this depends on your individual project but this shows the basic idea. you may need to add in other factors like telling the enemy to move on again when it has no target. alt text

alt text

capture.png (188.9 kB)
capture2.png (98.9 kB)
more ▼

answered Aug 22 '18 at 10:43 PM

avatar image

ThompsonN13
10.1k 33 10 25

avatar image ElectricTF Aug 28 '18 at 09:31 PM

Hello, I copied your code identically to my proyect, it didn't work. the enemies(those spheres) aren't damaging the turret(that weird black structure), they just keep piling up in that place. Maybe it is due to the collision?

Edit: I wanted them to do damage over time alt text

sin-titulo2.png (1.2 MB)
avatar image ThompsonN13 Aug 28 '18 at 11:31 PM

so you want them to apply a dot(damage over time debuff) and also to disappear on contact? also please confirm that some aspects are working for me. currently does this script apply damage to the turret? and are there any warnings or errors being thrown by the enigine? it should be ok but just asking to be thorough.

ok now on to making it work as you wanted. if you want the enemies to disappear on contact and apply a dot then its a pretty easy fix. the script currently is a dot system where its applying 10 damage every 1 second. as for the enemy disappearing im imagining a system like in wow where a debuff is applied for say 5 seconds, so it would be 10 damage every 1 second for 5 seconds. to do that you would just need to set the visibility / hidden in game on the actor which will make it not appear in game. then you need to disables the collision on the enemy actor so it doesnt interact with other actors (physically at least). you will then need a delay node and a destroy actor node, this will control for how long the enemy will exist and therefore for how long damage will be applied to the turret. all of these nodes would be inserted directly after the set timer. the last thing you need is to disconnect / delete the end overlap event seen in the picture as when you disable collision it may mess things up.

it should also be noted that if your currently not getting damaged to be applied then you may need to check you collision settings to ensure you have something that can overlap,

alt text

capture.png (224.2 kB)
avatar image ThompsonN13 Aug 28 '18 at 11:45 PM

hmm on a second read pf the original question it seems the above may not be what your looking for. do check the damage though and also post your current collision settings. you may just need to set something to overlap dynamic, generate overlap events, or add an extra collision volume.

(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