I access at a variable of Transform type in an another script and try to write its length with Debug.Log method but nothing is writer`
Moving Script:
public class Moving : MonoBehaviour {
private Spawn spawnScript;
void Awake ()
{
}
// Use this for initialization
void Start () {
spawnScript = GetComponent<Spawn>();
}
// Update is called once per frame
void Update () {
Debug.Log("Number WP: "+spawnScript.waypoints.Length);
}
}
Spawn script:
public class Spawn : MonoBehaviour {
// spawn Intervall
public float interval = 1.5f;
public int numOfEnemies;
float timeLeft = 0.0f;
public Transform[] waypoints;
private float distance;
private Quaternion newRot;
private Vector3 _direction;
public float velocityMove,velocityTurn;
// gameobject to be spawned
public GameObject enemy = null;
// Update is called once per frame
void Update () {
timeLeft -= Time.deltaTime;
if (timeLeft <= 0.0f && numOfEnemies > 0) {
// spawn
GameObject g = (GameObject)Instantiate(enemy,transform.position,Quaternion.identity);
numOfEnemies--;
timeLeft = interval;
}
}