Poolers (Part 2 of 4)

In some scenarios, the collection of “Poolable” items itself isn’t relevant to how you are using them. If you have no need of iterating over and applying logic to the entire group then you might be satisfied with using a simple “Set” to contain them. For example, an explosion might be pooled after its animation has completed and a bullet might be pooled after it hits an object or leaves a game zone. Scenario’s with event-based pooling might be a perfect fit for our first Pooler subclass.

Continue reading

Methods

The “action” part of programming comes from “calling” (also known as “invoking”) something called a “method” (also known as a “function”). In this lesson we will learn how to define and call our own methods, and then review a few more which are special to Unity. Finally, we will create our own “Magic 8 Ball” demo and cover how to link a method to the click of a button, and drive the output of a label. Continue reading

Your First Script

If you’ve never created a script before, don’t worry, it’s not exactly rocket science.  Learning to program is like learning a new language, but you are “talking” to the computer.  Just like a human language can be broken down into sentences which consist of a noun and a verb, programming languages can be broken down into variables (the noun) and methods (the verb) which are often paired in statements (the sentence).  Learning to program simply requires a bit of effort to learn the vocabulary and then to put it all together in a logical way. Continue reading