How AI can kill the player with view?

A branch ?

Use LineTraceByChannel for your raycast so you do not have to care about the length, just the start and the end. Here are more detailed informations about how to use it.