Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Game Development

Marc Martinez
Marc Martinez
12,909 Points

Frogs and logs -Modifying the game- -not part of the course-

I was messing around with the game after I completed the course and I was wondering if anybody knew how to add another duck or increase the ducks speed after the player collects around 20 flies. I just doing this for fun and trying to make the game a bit more harder, any help or ideas is greatly appreciated.

1 Answer

Damien Watson
Damien Watson
27,419 Points

Hi Marc,

Increase Bird Speed

The speed is pretty straight forward. If you open the 'BirdMovement' script, you will see the variable set 'birdAgent'. This variable links directly to the bird 'Nav Mesh Agent'.

In the update method, you can check the score and if above a certain amount, change the bird speed. You'll also need to change the angular speed. I have added in a few adjustments, you could stack these and probably make it cleaner but it will work.

BirdMovement.cs
void Update() {
  if (ScoreCounter.score > 20) {
    birdAgent.speed = 15;
    birdAgent.angularSpeed = 1000;
  } else if (ScoreCounter.score > 12) {
    birdAgent.speed = 10;
    birdAgent.angularSpeed = 860;
}

More Birds

All of the Birds settings are saved in the prefab, so you can Instantiate new birds similar to how the flies were created. The birds won't collide with each other by default and will end up walking in the same path, so there might be a few things for you to try.

Let me know how you go, definitely liking Unity3D at the moment. Cheers