yes, this can be used for enemy AI or other NPC's in the scene, not just the player. It is also not physics based, so there are many use cases for this snippet.
This could be used to chase the player if you wander into their sights or sneak up on them. But once they have sighted you, you need to use waypoint(spline paths) or navmesh(pathfinding) in order to follow the player around a complex environment, otherwise they end up running into a wall. The best way of saying is that it compliments a pathfinding solution(spline paths or navmesh).
Hope that makes sense
