I keep getting the error CS0120: An object reference is required to access non-static member ‘SimpleAI.Grid.GetCellIndex(UnityEngine.Vector3)’.
Here is the code the error is coming from:
void OnClick()
{ Vector3 gridPos = TouchHandler.worldPos;
int gridnum = SimpleAI.Grid.GetCellIndex(gridPos);
}
Here is the GetCellIndex code:
public int GetCellIndex(Vector3 pos)
{
if ( !IsInBounds(pos) )
{
return SimpleAI.Planning.Node.kInvalidIndex;
}
pos -= Origin;
int col = (int)(pos.x / m_cellSize);
int row = (int)(pos.z / m_cellSize);
return (row * m_numberOfColumns + col);
}
I’m new to Unity and C# so forgive me cause I know this error will probably be an easy fix. I’ve looked up the error and just can’t seem to wrap my head around what the problem is.