About 'Implementing A Ring Buffer'!

In this video (objectives)…

  1. Create a Tower Factory class
  2. Move the tower prefab, and max towers there
  3. Introduce this in C#
  4. Wire-up our tower factory, at least in outline.

After watching (learning outcomes)…

Use the this keyword to pass instances around.

(Unique Video Reference: 33_RR_CU2)

We would love to know…

  • What you found good about this lecture?
  • What we could do better?

Remember that you can reply to this topic, or create a new topic. The easiest way to create a new topic is to follow the link in Resources. That way the topic will…

  • Be in the correct forum (for the course).
  • Be in the right sub-forum (for the section)
  • Have the correct lecture tag.

Enjoy your stay in our thriving community!

Rather than store an numTowers integer, I just did this:-

if (FindObjectsOfType<Tower>().Length < towerLimit)
        {...

Out of curiosity, is either of these methods better than the other from an efficiency standpoint? The way I’ve used is just a check called at the time a tower is to be placed, but is it more expensive to call that, than just store an integer?

It depends on how the FindObjectsOfType is implemented but my guess would be that it is less work to save, increment, and compare an integer (which is just a few assembler instructions once compiled) than to query the objects list, which I assume requires at least some searching of memory. However, the difference in terms of modern PC processing power is probably negligible and the FindObjectsOfType command is giving you some practice in using Unity methods, which is one of the objects of the course.

Privacy & Terms