public void SpawnNextTrapObjectPrefab() { //usually called as an animation event LastTrapObjectPrefabSpawnPointIndex = TrabObjectPrefabSpawnPoints.NextIndex(LastTrapObjectPrefabSpawnPointIndex); Transform spawnPoint = TrabObjectPrefabSpawnPoints[LastTrapObjectPrefabSpawnPointIndex]; GameObject trapObject = GameObject.Instantiate(TrapObjectPrefab, spawnPoint.position, spawnPoint.rotation) as GameObject; TrapObject tr = (TrapObject)trapObject.GetOrAdd("Frontiers.World.Gameplay." + State.TrapObjectScript); tr.ParentTrap = this; }
public IEnumerator SpawnObjects() { for (;;) { TrapObject ob = Instantiate(SpawnObject, transform.position, transform.rotation); ob.SetVelocity(ProjectileSpeed, transform.forward); ob.SetDestroyTimer(ObjectLifeSpan); // Debug.Log("Spawned object"); yield return(new WaitForSeconds(SpawnDelay)); } }