In my project, my character can launch 4 different projectiles. How do I make it so that when an enemy is hit, it detects which projectile it was hit by, and then takes the appropriate amount of damage?
Every tutorial I have seen for projectile and enemy damage only allows for detection of one specific projectile, which is casted to on an On Component Begin Overlap event. This obviously wouldn’t work because I have multiple things with multiple values.
Every tutorial I have seen for
projectile and enemy damage only
allows for detection of one specific
projectile, which is casted to on an
On Component Begin Overlap event. This
obviously wouldn’t work because I have
multiple things with multiple values.
Precisely. Or you may not even have projectiles in your game. Or take fall damage or need to apply damage due to physical interaction, apply constant damage when nothing is happening until a specific condition is met… or do a bazillion other things that do not utilise projectile components or regular overlap / hit mechanics.
For something truly advanced, you may wish to write your own custom system. But the abovementioned damage system is generally enough in most cases.
Hm, this would definitely work, but I think I would want to go with an alternative method that is more efficient. The goal of the project I’m working on is to learn and in addition to that, the project will, in the end have MUCH more than just the four projectiles.
Ok, very interesting. I wasn’t familiar with the built in damage system. So would I want to break hit result on overlap and call Apply Damage to the hit actor?
I posted a comment earlier but it isn’t here, not sure what happened to it. Sort of new to these forums. Anyway… this definitely looks like what I’m looking for, I didn’t know UNreal had its own damage system worked in like this. The only thing now that I can’t seem to figure out is is the actual act of the two actors touching. My game is 2D and this is what I have, but of course, it isn’t working.
If I do a cast to a specific enemy, hitting that enemy with the projectile works fine when using apply damage. I just need to be able to detect what is being hit with the break result. I’ve been working at this for a bit now and my brain is fried from it, any ideas?
I tried that now and it seems to be working. I thought I tried it earlier though and couldn’t get it to work… Either way, thank you very much your help. ITts much appreciated!
I wouldn’t set it up like this either long term, I’d have a struct and a data table most likely, then you could run 1 loop on collision of an object, pass along an ID or something and then just have the loop return the damage amount in the data table.
I am glad you seem to have found the result you were looking for though. All the best.