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?
(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)
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.
Follow this question
Once you sign in you will be able to subscribe for any updates here