Strange ForLoop Behavior
Hi, thank you for reading!
I'm making a tower defense game. I have a tower that fires a homing projectile to its target, hits, applies a brief stun, and does damage to enemys within a certain range. Everything works correctly when the projectile doesn't do enough damage to kill the target. However, if the projectile kills the target, then the area of effect damage applies in a strange way...usually only targeting every other enemy in range when it should be targeting all of them.
For example, the AOE damages enemy1, enemy3, enemy5, enemy7, when it should be damaging EVERY enemy in range (enemy1, enemy2, enemy3, enemy4, enemy5, enemy6, enemy7, etc.).
The picture listed shows how I cast to the enemy actors. I am baffled by what is occurring, any ideas?
asked Mar 15 '17 at 08:23 PM in Blueprint Scripting
Yea thats what it was...I'm not exactly sure how the getOverlappingActors function works...maybe it fires every frame by itself, but having it plugged directly into the loop broke it. I had to set the getOverlappingActors function to a new array, then plug that array into the loop and now everything works. This seems redundant, but it works.
answered Mar 15 '17 at 11:40 PM
Have you tried placing a debug print statement if your IsValid check fails? I imagine TakeLightDamage may be queuing the Actor up for destroy and so the IsValid check would fail.
answered Mar 15 '17 at 08:51 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here