AI avoid hazard/laser

If you were making a 3D game, I would suggest using Environment Queries. However, in this case, I believe your solution is correct.