I need to get information on a list I made in a base class inside of a derived class. Is there anything special I need to do? Whenever I try to get the list.count the value just returns 0 every time. I’ve gone through the code letter by letter and nothing is wrong. list is public, semicolons, no misspellings. Help?
public class ShipBehavior : MonoBehaviour
{
public List<Vector3> position = new List<Vector3>();
protected void Start ()
{
SetPoints();
}
protected void SetPoints ()
{
position.Add(new Vector3(-2f, -0.9f, -4.5f));
position.Add(new Vector3(0f, -1.2f, -4.5f));
position.Add(new Vector3(2f, -0.9f, -4.5f));
}
}
public class BarrelParent : ShipBehavior
{
void Start ()
{
InvokeRepeating("Spawn", 2, 1.0f);
}
void Spawn ()
{
//outputs as 0
Debug.Log(position.Count.ToString());
}
}