Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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


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?"


Product Version: UE 4.21
more ▼

asked Mar 31 '19 at 12:22 PM in Using UE4

avatar image

144 8 17 22

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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.

alt text

capture.png (271.5 kB)
more ▼

answered Mar 31 '19 at 03:09 PM

avatar image

10.1k 33 9 23

avatar image leofucci Mar 31 '19 at 04:09 PM

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

avatar image leofucci Mar 31 '19 at 04:28 PM

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?

Thanks for your help!

avatar image ThompsonN13 Mar 31 '19 at 05:57 PM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question