Pathfinding using A* with 2D and a procedurally Generated Map

Hello I am trying to use A* to generate GridGraphs for my enemy to travel on and chase my player.

Now it works but when I try and make it move with the player to try and make sure as the player moves the grid updates and works for the infinite map. Now I am new to A* so I may be approaching this wrong but it is just so laggy when it has to rescan using Astar.active.Scan();

Any help understanding A* or even if there is a better option would be very helpful.

Judging by the code syntax - I guess you are using Aron Granberg’s Astar, right?
If that is the case, look into project’s documentation page:

https://arongranberg.com/astar/docs/

where you will find examples and explanations for common use cases and related issues. Like, for example, graph (re)generation:

https://arongranberg.com/astar/docs/graphgeneration.html

There is even this paragraph that proposes a solution to your problem already:

source:
https://arongranberg.com/astar/docs/largeworlds.html