NewObject usage and setup

The problem is here: GridLookup[N] = NewObject(UGrid::StaticClass());

When you use NewObject to create a UObject, the first parameter to be passed should be the Outer.

For example:
GridLookup[N] = NewObject(this);


Note:
If you want to pass a specific child class for this object, then pass the class name as the second parameter.
For example:
You have a BluePrint, which extends the UGrid, called BP_Grid.
In the BP_Grid you change parameters and input values that you want to use in the game.
In order to create objects using the BP_Grid, you have to pass the BP_Grid as class, then create objects using the BPGridClass:
GridLookup[N] = NewObject(this, BPGridClass);

The BPGridClass declaration in the .h file:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TSubclassOf BPGridClass;