September 2010
Beginner
384 pages
8h 49m
English
Ignoring the laws of physics for a second, let's look at the 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 FallingObjectScript. Change this line:
transform.position.y -= 1;
to:
transform.position.y -= speed;
Then for each object, input a different number for the speed value in the Inspector panel. Two objects, one script, and two different speeds. Awesome? Confirmed: awesome.
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 ...
Read now
Unlock full access