How to check if my character is AIMing the same actor for a certain period of time?

Hello,

I’d like to trigger an event when my character is aiming a certain actor for a period of time, in this case 2secs

That s what i’ve got but if I look at it 1/2 a sec, wait 1 sec and look at it again, it triggers too.

Thanks for your help!

Are you sure you are actually nullifying the hit actor variable after the 1 second delay if you aren’t still looking at the same actor? You should print strings for that variable at each step and see what it reads out. Nothing is hooked up to the “set” value so it may not be resetting…you might want to add in a dummy actor just to nullify the variable.

Second, I would just use a timeline or tick with a gate to line trace to your actor, then have a sequence following this with the first output consisting of “Do once” followed by, set hit actor, followed by a retriggerable delay set for 2 seconds and finally by your desired logic if you maintain 2 seconds of gaze at the same actor. The second output pin will have a branch checking if the current line trace object = the “hit” actor from the previous step, so as long as you are still looking at the same actor this will be true and execute nothing from the true execution pin. If 2 seconds pass, the retriggerable delay will execute through to the desired logic and at the end you can close the tick gate, or stop the timeline to prevent unnecessary tick use. However, if it becomes false at any point which would occur by looking at a new actor, the line trace and the prior set hit actor would be unequal, you would then “reset” the do once allowing execution to flow through, resetting the “hit actor” and hitting the retriggerable delay preventing it from firing if it has not been 2 seconds yet.

I never think of retriggerable delays…

It works fine Thank you!