Look during x time / Trace x time


I have a trace from the HMD (VR, although it is not relevant, because it would be the same without being vr), and I want that when I’m looking to an object (The hit works) for ‘x’ time do something.

In this case i want 3 seconds looking to a mesh, and start a function.

I tried to get the time, and add 3 and compare the time again, but I think I did it wrong, because it doesn’t work for me, or because there is no way to do it in that way…

¿Any idea? Greetings!

Keep the hit object in a variable.

Each tick trace and compare the hit against the variable. When detecting a change

-save the new hit to the variable

-clear and invalidate the timer handle

-start a 3 seconds timer and save the timer handle

Hey, thanks for the answer. I’ve finally done this following your comment. At the moment it is working…

If you see something wrong, I am happy to correct it.

Somewhat correct. Depends on your needs.
Though I assume you want to reset the timer every time you look at another object or no object, so you need to do the comparison right after the trace and get rid of the DoOnce