Hello. I have been trying to follow this tutorial for tactics like character movement. With minor tweak from the video’s comments to the code, I was hoping that would make it possible to use hexagonal tiles instead of square ones. However I am running across errors called CS0103 within unity and have no understanding how to add or change the code to get rid of the problem.
Errors:
Assets\TileMap.cs(45,66): error CS0103: The name ‘xPos’ does not exist in the current context
Assets\TileMap.cs(45,77): error CS0103: The name ‘ZOffset’ does not exist in the current context
and code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TileMap : MonoBehaviour
{
public TileType[] tileTypes;
int[,] tiles;
int mapSizeX = 10;
int mapSizeY = 10;
// Start is called before the first frame update
void Start()
{
tiles = new int[mapSizeX, mapSizeY];
for (int x = 0; x < mapSizeX; x++)
{
for (int y = 0; y < mapSizeY; y++)
{
tiles[x, y] = 0;
}
}
GenerateMapVisual();
}
void GenerateMapVisual()
{
for (int x = 0; x < mapSizeX; x++)
{
for (int y = 0; y < mapSizeY; y++)
{
TileType tt = tileTypes[tiles[x, y]];
Instantiate (tt.tileVisualPrefab as GameObject, new Vector3 (xPos, 0, y*ZOffset), Quaternion.identity);
}
}
}
}
I am sure the answer is simple, but I hope someone here will be able to help me either way? Thank you