Spawner Spawner Spawner: Class, prefab & script

So, I was feeling pretty happy with myself but feel like I’ve lost the plot on this lecture. Hopefully writing this out with help me resolve my confuddle. This stems from the challenge @ 07:14 - setting the myLaneSpawner and looking at what is in the lane.

I think the root of my issue is I am not sure what the ask of the challenge is, but going on from that I think we need to:-

  1. Iterate through the Spawner prefabs shown in scene view (mine were called Lane1, Lane2 etc under the parent Spawners
  2. Check if and of the Lanes has spawned an attacker, lizzer or foxey
  3. Because of our nice neat instantiate within parents, each row or lane could have child objects and you see these spawn nested nicely in scene view

My confusion is, that we are iterating through the Lane1,2,3 gameObject instances, and looking for ‘Spawners’ - which are what? Classes? I cannot resolve why this isnt an iteration through the Lane1,2,3 instances exercise to see if we have children attackers spawned under them. Why do we create a local reference to the Spawner (script / class) and not grab the child game object?

See, told you I was confused!

SO update if its of interest!

I was trying to solve what I thought was needed not what Ben was asking for. Having slept on it, my mind has resolved to this (please comment if it’s wrong!)

  1. set myLaneSpawner - all we need to do is to find the little spawning point for the row that [this] shooter is in and create a local reference to that object and store it in this.shooter
  2. if you have 8 defenders on screen that have the ability to shoot, you’ll actually have 8 references being created to one of the 5 attacker spawning gameobjects)
  3. In my case the script I attached to the empty game objects used in each row to spawn critters was called SpawnManager. By attaching this script to an object in the scene, I have create an instance of the class SpawnManager for each spawner
  4. The ask therefore is to first iterate through all the SpawnManager classes (in my game and Ben’s there are 5, 1 in each row) and find the spawnManager that has the same transform.position.y as this.shooter
  5. when you find it, set it to the local reference. This means every shooter, or every defender you place that has a shooter class attached to it will have a copy of the spawner in its lane (or row or ‘y’ position)
  6. That’s all there is to the calling @ 07:14. I was confusing things by trying to solve the challenge that comes at 12:27 where we look at that local reference of spawner for that shooter to see if it has children and getting myelf in a muddle about what a ‘class’ is.

Feel free to delete this post Admins, as I have solved my own topic, but thought it might be interesting to share the thought process I went through.

Privacy & Terms