Very variable?

You may already be sending up warning flags about this madcap plan to use one script for two different objects. What if we wanted the bomb to travel at a different speed than the beer stein? And don't we want two completely different reactions depending on whether the player collides with the bomb or the stein?

We'll answer the collision question a little later in the chapter, and we'll tackle the variable speed question now. But before we do, fire up your gray matter. How would you solve this problem? How would you make the objects move at two different speeds, with two different collision reactions, and still use the same script?

Get Unity 4.x Game Development by Example Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.