I have test CODE #1 to load strategy game information for map terrain and units. At anytime a player can exit to the main menu to load a new game. CODE #1 is in a separate class which requires no object.
CODE #1
using UnityEngine;
using System.Collections;
public class LoadCGN {
//loads terrain data from file into array from random numbers. Later this will be a file read.
public void TerrainMap () {
for(int x=0; x < Game.fullMapDimX; x++) {
for(int y=0; y < Game.fullMapDimY; y++) {
Game.terrainMap[x,y] = Random.Range(1,480);
}
}
}
public void UnitMap () {
for(int x=0; x < Game.fullMapDimX; x++) {
for(int y=0; y < Game.fullMapDimY; y++) {
Game.unitMap[x,y] = Random.Range(1,8);
}
}
}
}
CODE #2 is suppose to load the data from the CODE#1 above and create the map mesh.
CODE #2
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
[RequireComponent(typeof(MeshFilter))]
[RequireComponent(typeof(MeshRenderer))]
public class TerrainMeshBuilder : MonoBehaviour
{
//other code here
LoadCGN.TerrainMap (); //load map data
//build mesh code here
}
I keep getting the error below and I can’t find a “laymen’s terms” answer on it via my research.
Assets/Scripts/TerrainMeshBuilder.cs(58,25): error CS0120: An object reference is required to access non-static member `LoadCGN.TerrainMap()’