void SetupTarget(SpawnPathInfo spawnInfo, Transform pathParent) { var targetParent = Instantiate(spawnInfo.target, transform); targetParent.lifetime = spawnInfo.targetLifetime; SetupInOutScalerTriggers(targetParent); var pathMover = targetParent.gameObject.AddComponent <PathMover>(); var actualTarget = targetParent.GetComponentInChildren <TargetCollider> ().gameObject; actualTarget.transform.localScale = spawnInfo.scale; if (spawnInfo.facePlayerAlways) { var lookAt = actualTarget.AddComponent <LookAt> (); lookAt.target = Vector3.zero; lookAt.onlyXZDirection = true; lookAt.continuous = spawnInfo.facePlayerAlways; } var path = new Transform[pathParent.childCount]; for (var i = 0; i < path.Length; i++) { path [i] = pathParent.GetChild(i); } pathMover.path = path; pathMover.time = spawnInfo.targetLifetime; pathMover.space = Space.World; }
void SetupSpawningInfos() { int startIndex = 0; if (initialSpawnDelay > 0) { spawnings = new SpawnPathInfo[targetSpawns.Length + 1]; spawnings [0] = SpawnPathInfo.Empty(initialSpawnDelay); startIndex = 1; } else { spawnings = new SpawnPathInfo[targetSpawns.Length]; } for (var i = 0; i < targetSpawns.Length; i++) { spawnings [i + startIndex] = targetSpawns [i]; } }