Time for action – creating the yellow bird

Because of the power of inheritance, the script we are creating here consists of only a handful of lines of code:

  1. Start by creating the yellow bird in the same way as the red bird, using the YellowBird model instead.
  2. Instead of using the Bird script, we will create the YellowBird script.
  3. This script needs to extend the Bird script, so replace MonoBehaviour with Bird on line four. It should look similar to the following code snippet:
    public class YellowBird : Bird {
  4. This script adds a single variable that will be used to multiply the bird's current velocity.
    public float multiplier = 2f;
  5. Next, we override the DoSpecial function and multiply the bird's rigidbody.velocity when it is called:
    protected override void ...

Get Unity Android 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.