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

Hi. Perhaps, my solution will help anyone.

  1. In ‘On See Pawn’ I set bool ‘IsSeeingPlayer’ to true for ‘SensingInterval’ seconds. I do that so that ‘Event Tick’ would register the value for this interval. Afterwards, I reset the bool to false.
  2. In tick I call event ‘Update Sight’.
  3. In this event I used me macro ‘Bool Trigger’. This macro receives a bool variable (‘IsSeeingPlayer’ in our case) as input. The macro continues execution only if the input value changed in comparison with previous run. For example, if previously the input was true, and now it is false, ‘False Exec’ will fire. It is vice versa with ‘false’ → ‘true’. In case the value remains same, it stops executing. All in all, it is similar to ‘DoOnce’ macro with branch notifying that the value changed plugged into ‘Reset’ pin.
    I use this macro to tell whether the sight status of the player has changed this frame . If so, I can perform my logic, depending on whether the AI stopped or started seeing the player.
  4. Here I apply my code for the macro. I also added input ‘Skip first’ to avoid the situation when the macro continues execution when called for the 1st time. It is similar to ‘Start closed’ pin in ‘DoOnce’ macro.

    image
    image