Terminal velocity is a myth – bombs fall faster
Ignoring the laws of physics for a second, let's look at how to make the two objects fall at different speeds using the same script. One solution is to declare a variable called speed
at the top of the FallingObject script.
var speed:int;
Change the following line:
transform.position.y -= 50 * Time.deltaTime;
to:
transform.position.y -= speed * Time.deltaTime;
Then for each object—the bomb and stein Prefabs—input a different number for the speed value in the Inspector panel. Try 30 for the stein and 50 for the bomb. Two objects, one script, and two different speeds. Awesome? Confirmed: awesome.
Tip
Know when to double down
At some point, objects become different enough that sharing a script is no longer saving you time and effort, it's causing you grief. As a game developer, you need to decide what sort of structure best suits your game-creating goal. Programmers have all kinds of tricks to save themselves work and to logically structure their code...