Time for action – creating the black bird
As with the two birds discussed earlier, inheriting from the red bird makes the black bird's creation much easier:
- As with the others, this bird is initially created in the same way as the red bird, readjusting the Radius for its increased size.
- Again, we create a new script to extend the
Bird
script. This time it is calledBlackBird
. - Do not forget to adjust line four to extend the
Bird
script and notMonoBehaviour
.public class BlackBird : Bird {
- This script has two variables. The first is the size of the explosion and the second is its strength.
public float radius = 2.5f; public float power = 25f;
- Once more we override the
DoSpecial
function, first marking that we did it. Next, we usePhysics.OverlapSphere ...
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.