# How to know if an actor is hit on his front/back?

Hi

So I have a very specific scenario, a good example to keep it easy could be, imagine the typical flashbang, you trow a flashbang to the enemy, if enemy is near enough, he will be blinded.

But what about if the enemy is near enough + is looking at the flashbang?

I would like to avoid being blinded if the flash happens on his back.

How can I achieve this? I guess it should be some formula to check if player is looking at the center (location) of the explosion, right? but how? and also… I guess it shouldn´t work like with an exact value, because player has 90 degrees of FOV, so I guess formula should be something “is looking at … from here to here?”

Thanks!

how about getting the look at rotation then comparing the yaw of the character to that. if its within say +/- 45 then you affect them. i made a quick little test script and it seems to work from the preliminary testing i did.

So the trick is “Find At Look Rotation”… i´m checking if that does the trick, be right back.

It works, but i´m still trying to understand what happened here. Is this right?

1. get all actors in the radius of my flashbang- ok.
2. take an actor, get his location and find which rotation should have if he would like to see the flashbang. -is this right?
3. get actual actor rotation - ok.
4. compare if actual rotation is inside -90 and 90, if true it means it is inside angle needed to see the nade.

also…
Would this -90 to 90 work for a Field of view of 90? because sounds like it´s taking 180 right?

2 its basically saying what rotation would i be if i wanted to look directly at this things origin. so yea your pretty much spot on.

the 90 degree bit i was just using for testing so you may need to tweak it to another number. im not sure on the field of view so thats again something you may need to play with. when i was testing it instead of getting the overlap and the loop i just plugged in a reference to my character and fires everything on tick. that may be a good way to test the angle needed since you can get a feel for the ballpark of its value via the print string.

Hi, May be your idea is good but don’t know why not working properly in my end.

I am using UE5 where the character default rotation yaw is set to 270 and when i use the code in the solution it shows i am front of AI when i am only in it’s left side. For rest of the area it shows i am back side of AI.

I tried different values but not finding the exact one to fix this part.

Can anyone help me in this situation??

Ok so found the solution for this and sharing so that if anybody is facing same issue like me in UE5 can resolve that.