I’m trying to make an enemy character teleport to a random location after it has been looked for 3 seconds. I know how to make it teleport im just trying to figure out how to make this happen when it has been looked at for 3 seconds without breaking eyecontact.
you can line trace from the camera unsing camera forward vector direction and put some trace collider in the character. If trace is hit then you can start some 3 sec timer and then run asome function…while timer is running you can evaluate the hit so if is not hitting anymore you can just clear the timer.
If by “being looked at” you mean the camera facing straight at the said actor instead of just having it on the screen, you can use the approach @eldany.uy has explained. However, if you mean the other option, you might consider checking if the actor is being rendered. There might still be additional things to consider while implementing this approach so I did a little research and found this post: Check if actor is visible to player - #2 by SupportiveEntity
Under this topic, you can inspect other posts to further enhance the reliability but I think the post I included here will be sufficient in your case