public void SpawnObject(GameObject obj, int index) { lastSpawn = 0; Vector3 startPos = movePoint[index]; startPos.y = obj.transform.position.y; startPos.z += spawnDistance; ISpawnable spawned = Instantiate(obj, startPos, obj.transform.rotation, spawnedObjectParent).GetComponent <ISpawnable>(); spawned.Initialize(direction, index); }