Hello,
I wrote the following script to store the initial position of few gameobjects. The script is attached to each gameobject :
using UnityEngine;
using System.Collections;
public class ProprietePieces : MonoBehaviour
{
public static Vector3 PositionInitialePiece;
// Use this for initialization
void Start()
{
PositionInitialePiece = gameObject.transform.position;
}
}
My problem is that I do not succeed to access the “PositionInitialePiece” variable from another script. Here is what I use :
ProprietePieces ScriptProprietePieces = gameObject.GetComponent<ProprietePieces>();
Debug.Log(ScriptProprietePieces.PositionInitialePiece);
I get an error message saying that “Member ProprietePieces.PositionInitialePiece is not reachable with an instance reference, use a type name”
I do not understand what is the problem, and hope someone could help me.