x

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"

Flashlight should stops AI movement, then resume movement when flashlight isn't shining on them

The idea is that when the flashlight is shining on any AI, it pauses their movement until the light is no longer shining on them. I've used Line Trace to detect when its on them or not.

As you can see below. I've told The AI to Patrol then chase me unless flashlight is on and shining on him. However I've noticed that the AI only stops when you(the pawn) are directly facing it with the flashlight. The AI doesn't care when the flashlight's linetrace is behind an object. And even outputs that it is paused(stop movement) in printscreen when the flashlight is turned off but facing the AI. Very odd! alt text

I've also posted my turn on and off blueprint for the flashlight as well in case I'm missing something obvious Turn on and Off Flashlight Blueprint
![alt text

Product Version: UE 4.20
Tags:
more ▼

asked Aug 13 '18 at 02:17 PM in Blueprint Scripting

avatar image

f00d4tehg0dz
5 1 3

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

1 answer: sort voted first

If you turn on the debug for duration of 10 seconds on the Line Trace node, does it show the red line going through obstacles, or does it turn green at the point it hits the obstacle?

If it stays red for the entire length of the line, then it's not hitting the obstacle, and you might need to try Trace by Object Type or something instead, and feed a MakeArray of WorldStatic and one or two others into it for the collision Object Type.

more ▼

answered Aug 13 '18 at 04:24 PM

avatar image

mightyenigma
3.8k 18 20 20

avatar image f00d4tehg0dz Aug 13 '18 at 09:57 PM

Trace by Object Type works!!! However as you can see in this gif below. The AI doesn't resume after being flashed on. It actually seems to only care once I turn the light on or off function. Not the actual light itself. Wondering if I made a mistake in the flashlight? Gif link https://imgur.com/a/Z0iLB8E

You can see my blueprint for flashlight above. But i posted snippets here too! alt text alt text alt text alt text

turn-on.png (148.4 kB)
gate.png (201.9 kB)
inrange.png (199.9 kB)
flashlightsee.png (157.3 kB)
avatar image mightyenigma Dec 11 '18 at 09:59 PM

Sorry i have been away from this thread so long. I let my inbox get flooded with too many answerhub notifications and so i recently turned off most of them.

It is hard to tell whats wrong here but it might help with troubleshooting if you move the logic out of the flashlight and into the monsters since they are the ones who care whether the flashlight is shining on them. The flashlight doesnt need to know anything about monsters. You can do it that way but it makes it more complicated.

If a trace from the monster toward the flashlight hits the flashlight, and the flashlight rotation is within -0.2 dot product of the monster's trace direction, then the flashlight is facing the monster or close to it and the monster can tell itself to freeze---- or unfreeze if the trace is out of range or a dot product of less than -0.2 or more than 0.

That way you dont have to do complicated gates and loops because each monster handles its own freezing and unfreezing.

avatar image f00d4tehg0dz Jan 14 '19 at 03:57 PM

hey no worries! I ended up doing an invisible cone attached to the flashlight for object detection. I was having a ton of trouble with tracing, but I really like your idea here. If I get time to revist the base logic, I will most definitely do so. Thank you! I'll mark this as completed.

(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