How do I get an enemy to come to the player/ attack the player on sight or when it gets close?
Develop games in your browser. Powerful, performant & highly capable.
Check these tutorials:
https://www.scirra.com/tutorials/search?q=enemy%20ai