So I have a really specific problem, and I am not the best at Unity C# by a longshot. Hopefully this will be a learning opportunity.
I am trying to make a simple chess game. So far every space on the board is it’s own GameObject with a 2 character string name consisting of the board column (A-H) and the board row (1-8).
I have defined the following BoardSpace class which is attached to every BoardSpace GameObject in my scene.
using UnityEngine;
using System.Collections;
public class BoardSpace : MonoBehaviour {
char SpaceColumn;
char SpaceRow;
int SpaceColor;
}
I want to be able to set the SpaceColumn and SpaceRow fields to the first and second characters of the GameObject the script is attached to (respectively.)
I have tried using an assignment with gameObject and keep getting an error that the assignment operator is an invalid token. I don’t understand the problem and could use some insight.
ex. SpaceColumn = gameobject.name[0];