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?”
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.
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.