Question about applying damage to the player without player being hit

I was wondering is it possible to apply damage to a player when they shoot something? For example, say a play shoots a trigger box and the trigger box will then apply damage to the player when the projectile overlaps with the box. Another example could be when the player shoots a target and misses, would it be possible fo apply damage to the player when the projectile is destroyed after the physics are down simulating on the projectile. Been trying to figure this out but all the tutorials i find talk about applying damage when the player character enters the trigger box or is hit.

you can apply damage to the player or any other actor at anytime you wish as long as you have a reference to the thing you want to damage.

for your box example you would assign a variable in your bullet for who created it, then on begin overlap in the box you would get the variable then apply damage to the one that created the bullet.

its basically the same for all the other examples, have the bullet know who created it (character reference) then when you want to apply damage get the reference and apply damage. easy peasy.

ok another example, in the below picture you will see a bullet script with two conditions which will apply damage to either the player who spawned the bullet or to another character. i set it up so that if after 5 seconds if the bullet hasnt hit another character then it will damage the character that created it. this is done via the begin play delay combo. another thing to note here is the variable is set to public and i have expose on spawn checked. what expose on spawn does is create another pin on nodes like the spawn actor of class so you are able to set the variable when the bullet is created.

this is probably a bad explanation but its a rather simple thing so im sure you can figure it out.

hello Thompson,
i am trying to create a blueprint that will damage the player when the first person projectile misses it’s target so to speak. so basically player shoots and if they hit the target then they dont receive damage but if they miss then they recieve damage. i have tried to recreate what you explained for the second example but i think i am doing something wrong. i am trying to build this in the firstperson projectile blueprint. here is my work if you wish to analyze.

Thats pretty much what the wxample picture i posted does. The issue with your situation is you need a way to tell the projectile what is target is and if it missed the target. In the example i posted i solved the issue of knowing the target by having the target be any character hence the cast node, the knowing it missed is another matter which has so simple solution so i went with the idea if it hasnt hit its target after x seconds then it probably missed this is done witth the delay. Mow these methods ised are just an example and you need to come up wih how you want to define the conditions based on the context of your project.

You pretty much have made hhe first part of my example though you havent shown how you set the character reference and you used a more direct method decreasing health ( i would make use of the apply damage and event any damage nodes for organizations sake). For setting the character reference my method was to use a variable exposed on spawn so it could be set from the spwn actor node.

I posted this from my phone so excuse the spelling

your fine, for the reference i basically created a variable in the projectile that stores the data of the first person character for the reference