[Godot Mono C#]
When I GetNode, should I put it in the Ready Method and then have fields OR should I only put it in the methods that need it?
Example 1:
private TileMap mazeTm;
public override void _Ready()
{
mazeTm = GetNode<TileMap>("/root/Game/MazeContainer/Maze/MazeTilemap");
}
public void AddNodeToTilemap(Vector2 pos)
{
mazeTm.SetCellv(pos,node);
}
public override void _Process()
{
AddNodeToTilemap();
}
OR
Example 2:
public void AddNodeToTilemap(Vector2 pos)
{
TileMap mazeTm = GetNode<TileMap>("/root/Game/MazeContainer/Maze/MazeTilemap");
mazeTm.SetCellv(pos,node);
}
public override void _Process()
{
AddNodeToTilemap();
}
Also, if I GetNode in the process function like in 'Example 2', is that worse for performance than doing what I did in 'Example 1' or is that not how it works? OR, is the difference in performance so minimal, I should just do Example 2 as it has better readabillity/ is better for code in some way?