0
public class BoardLocations : MonoBehaviour
{
    public GameObject A1;
    public class Coords
    {
        public Vector3 aOne = A1.transform.position;
    }
}

This is all in one script, attached to an empty game object. The error I get is "An object reference is required for the non-static field, method or property 'BoardLocations.A1'". The only way to make the error go away is to make the GameObject and Vector3 static, but doing that means I can't see the GameObject in the inspector, which I need to assign the GameObject. Placing the GameObject in the same class as the Vector3 yields the same results. How can I reference the GameObject in the class so the Vector3 can see it?

D.J.
  • 3,644
  • 2
  • 15
  • 22
R. Wagar
  • 1
  • 1

1 Answers1

1

your class coords is not having 'BoardLocations' reference. your code should be like `public class Coords {

public Vector3 aOne;

void Start()
{
    stackof se = new stackof();
    GameObject e = se.A1;
    aOne = e.transform.position;

}
}`