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"

How to tell when a pawn is no longer sensed (pawnsensing)

I'm trying to create an array of pawns that are currently sensed in blueprint, but it seems there is only a "on pawn sensed" and not "on pawn lost". Unreal clearly internally registers when a pawn is lost, but it can't figure out how to make it tell me.

Product Version: UE 4.12
Tags:
more ▼

asked Jun 28 '16 at 07:51 AM in Blueprint Scripting

avatar image

Jarbles
123 9 12 18

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

4 answers: sort voted first

Hi there!

Not sure if you've found the answer yourself by now, but I spent days trying to work it out!

Turns out all you need to do is set a bool from your OnPawnSee event, run into a sequence, from there have the first pin run to what action you want to preform, mine is to print 'Sight' then fire a custom event. On the second pin, have a retriggerable delay of a value higher than your Pawn Sensing Components sensing interval (Default is 0.5 so I set my delay at 0.6), Then have that run into your bool setting it false. Job done!:)

Heres a picture to illustrate what I mean Hope it helps! alt text

seeing.png (118.3 kB)
more ▼

answered Sep 18 '16 at 11:13 PM

avatar image

Matt_0114
116 2 7 6

avatar image leslienggg Sep 25 '16 at 01:46 PM

Hi!

I have the same problem as the person who started this post.

I've tried doing a sphere trace to check if my AI character can see the player in my OnSeePawn event before my AI MoveTo and if it can, it will run towards the player, but it's kinda broken and the AI can still run towards the player even after the player hides behind walls.

I have seen your solution but I can't seem to understand how it works, in particular the event "Reset Sense" and why having a retriggerable delay of a value higher than the sensing interval. What is actually in the event that causes the sensing to reset and how does the delay solve the problem?

avatar image Estape Dec 04 '17 at 02:44 PM

Works like charm, thank-you!

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

Hi there!

Sorry, must've forgotten the reset sense bit! Also this is going to be really long but bear with me:)

Reset Sense:

All it does is fire the reset pin of a Do Once node (The Do Once node just goes to whatever code you want to run when he sees the player). This is useful if you do not want your action to be performed every sensing interval, and rather once when initially he sees you. So the flow will be the OnSeePawn firing, setting off the custom event Seen Target, then that event running through a Do Once node. I've done this because after my Do Once node I have him move from place to place firing a gun with various delays (That code isn't visible in the picture in case you were confused), but I only want that process to be started once when he sees me, and not every 0.5 seconds that OnSeePawn fires, so Ive used the Do Once node. The Reset Sense simply resets the Do Once node when the player is out of sight (How it fires at the right time is explained below) meaning when the player is in sight, Seen Target will fire, and be able to pass through the Do Once node again. ![alt text][1]

Retriggerable Delay:

As to the retriggerable delay, this value must be higher than the pawn sensing interval so that it never fires whilst the pawn is in sight. Every 0.5 seconds the OnSeePawn checks if the player is in sight and fires if true, starting the retriggerable delay to count down from 0.6. Now, once the retriggerable delay gets to 0.1 seconds left, 0.5 seconds has passed and the OnSeePawn event checks if the player is in sight, and if true, fires, resetting the retriggerble delay back to 0.6, meaning the bool 'See Enemy' doesnt get set to false. If however when there is 0.1 seconds left on the retriggerable delay and the OnSeePawn checks if the player is in sight, and returns false, it wont fire. Therefore the retriggerable delay wont be reset and will count down to zero, then firing the bool setting See Enemy to false. See the photo above.

How to use the See Enemy Bool:

To make the Ai stop chasing you when you go out of sight, you need to check the value of the See Enemy bool. The only way I can think of to do that (My Ai dont chase so its slightly different) would be to have a delay after your Ai Move To node of however many seconds you like (Experiment abit, whatever suits your game best, start at 1 and see how it goes) hooked up to a branch with See Enemy as the condition, if true, have the pin loop back into the Ai move to, if false, have the Ai move to a different location or whatever you'd like to do with him. Below is a quick mock up of what I mean

![alt text][2]

Hope this helps! I know it was long sorry, let me know how it goes:)

Matt [1]: /storage/temp/108456-seeing+reset.png [2]: /storage/temp/108458-stopchase.png

seeing reset.png (167.6 kB)
stopchase.png (101.0 kB)
more ▼

answered Sep 25 '16 at 11:40 PM

avatar image

Matt_0114
116 2 7 6

avatar image Matt_0114 Sep 25 '16 at 11:42 PM

Cool, pictures didnt work, so helpful....

Where you see alt text 1 look at the seeing reset.png Where you see alt text 2 look at the stopchase.png

avatar image leslienggg Oct 01 '16 at 05:37 PM

Oh my gosh man. You are a lifesaver! I had to tweak some part of the blueprint to fit, but now it works like a charm! THANK YOU SO, SO MUCH! You don't know how much this means to me!

avatar image Matt_0114 Oct 04 '16 at 11:27 PM

You're Welcome!:) Glad I could be of help haha Anything else you need let me know!

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

Mate, thankyou for this, works just like I wanted

more ▼

answered Jan 18 '17 at 07:18 AM

avatar image

blisters50
28 2 4

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

In my case I have a radius where the enemy can see the player, 10,000.00 units for example, every 100 milliseconds I verify if the player is in that radius, if hes not in the radius I'll set variable isPawnSensed to false. Because in my case is hard to the enemy see the player, if I base my logic on the PawnSensing Component player again, but not a radius, I wont have too much control over it and I think its not going to feel good to my game.

more ▼

answered May 30 '19 at 08:16 PM

avatar image

thecodermarcelo
1 2 2

(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