Reader small image

You're reading from  Game Development with Blender and Godot

Product typeBook
Published inSep 2022
Reading LevelBeginner
PublisherPackt
ISBN-139781801816021
Edition1st Edition
Right arrow
Author (1)
Kumsal Obuz
Kumsal Obuz
author image
Kumsal Obuz

Kumsal Obuz is a self taught, but veteran web developer with more than 15 years of experience in two different countries, leading teams and projects of various sizes. After several years of preparation and transition, he started his own game studio in August 2020. He launched a small puzzle strategy game at the end of 2020 and is currently working on an ambitious farming simulation game. He also likes to mentor, perhaps due to his genetic background since both of his parents are teachers, and because of his love of Godot, founded and still organizes the Godot Toronto Meetup group.
Read more about Kumsal Obuz

Right arrow

Finishing with Sound and Animation

We’re in the home stretch. The effort we started back in Chapter 9, Designing the Level, was resumed by making the level look more exciting in Chapter 10, Making Things Look Better with Lights and Shadows, which led us to implement a basic user interface in Chapter 11, Creating the User Interface. We built new mechanics in Chapter 12, Interacting with the World through Camera and Character Controllers, so we could interact with the world we have created. As a result, Clara is now able to press the parchment left by her uncle, and she can also walk around. This is all very nice, and we can take it a step further by refining some rough edges.

It’s all quiet in here! As she’s walking, we should trigger an audio file that will simulate her footsteps. While we are at it, we will also add background music and effects that will better reflect the qualities of the environment Clara is in.

You must have noticed that, as Clara walks...

Technical requirements

It’s perfectly fine if you would like to continue where you left off in the previous chapter. However, there are some extra resources you will need to finish the work in this chapter. You can merge these assets with the rest of your project files. They are in the Resources folder next to the Finish folder in this book’s repository that can be found at https://github.com/PacktPublishing/Game-Development-with-Blender-and-Godot.

Playing music and sound effects

Music and sound effects sometimes can make or break the enjoyment people get out of movies, theatre plays, and of course, video games. When done right, they will definitely add to the immersion. In this section, we’ll tackle the use of music and sound effects from a technical point of view. In your own free time, we suggest you investigate the artistic aspects of sound design in multimedia for which we’ll mention a few resources later on in the Further reading section.

In Chapter 8, Adding Sound Assets, we discussed different nodes Godot uses to play sound in different dimensions, as follows:

  • AudioStreamPlayer3D for conveying 3D positional information to the player. It’s most commonly used in FPS games where not only front and back directions matter, but an audio stream coming from an elevated place is important as well.
  • AudioStreamPlayer2D for games in which the direction the sound is coming from doesn’t need...

Creating reaction spots

When the player clicks on the parchment, the game shows the content written on that parchment via a user interface. When the player clicks on a particular location in the world, Clara walks to that spot by playing a walking animation and playing a footsteps sound. These are all direct interactions at the player’s end, which brings us to discuss cases when the game should react to indirect events.

Although not lit, Clara is holding a torch. You already know how to use the Light nodes in Godot. So, it’s easy to place OmniLight near the torch mesh inside the Clara node. Our basic expectation is that, when she walks by the candles on the floor and the sconces on the walls, she’ll be lighting those up using her torch. Thus, the game needs to know when she’s near some objects.

Let’s first give Clara a torch she can carry around, then we can proceed to discuss how this torch can affect other objects in the level, as follows...

Building simple animations in Godot

Back in Chapter 5, Setting Up Animation and Rigging, we discussed variances between Blender and Godot Engine for animation needs. In summary, we claimed that you’d be better off with Blender for animating anything more complex than bouncing balls and simple rotating objects. To drive the point home, we rigged and animated a snake model. Similarly, we have been using a humanoid character, Clara, done in Blender as well.

However, there comes a time when it might be suitable to animate some of the models in the game engine. The topic we have at hand is the opening animation of the arched door Clara is standing in front of. If you prefer so, you could still open the model in Blender, implement the necessary steps that represent the opening of the door, and reimport your work in Godot. It’ll be no different than any other imported model that came with its animation.

For such a simple task, it’s a bit of an overkill, though...

Loading another level

Before we started to animate the light sources in the Let there be flickering lights section, we were ready to move Clara upstairs. To that end, we used a nifty feature of the AnimationPlayer node to fire the load_level function, which printed a statement to the Output panel, a substitution for the real thing. In this section, we’ll investigate how to swap the existing level with another.

Let us remind you that our current level, Level-01.tscn, is instanced inside the Game.tscn scene, which is holding a Camera and an AudioStreamPlayer type of nodes. Godot has a built-in function, change_scene, that can change the current scene to another scene. However, this might be dangerous since it’ll replace the entire structure. In our case, this is not Level-01.tscn but everything in Game.tscn because that’s the main scene.

The solution we’ll offer is a process that’s operational at a higher level than Level-01.tscn itself. Ideally...

Summary

This was another chapter with a lot of moving parts that incorporated so many different aspects of the game engine. Let’s break down some of your activities that helped to add the finishing touches on so many things we carried over from the previous chapters.

First, you tackled background music and sound effects. You had already seen the usage of sound in Chapter 8, Adding Sound Assets, which covered simple scenarios. In this chapter, you’ve learned how to use sound assets in a proper context.

Next, you reexamined a topic you saw in Chapter 12, Interacting with the World through Camera and Character Controllers – player detection. This time, you used Area nodes as trigger zones since there would not be direct player interaction, such as mouse clicks and motion. Instead, Clara triggers predetermined events when she’s in the right zone.

You were also able to communicate information between game objects, essentially separate and distant systems...

Further reading

As promised, we want to share with you a few words on the artistic aspects of sound management. Sometimes, a piece of music will have a high tempo. It means it’ll have a higher value of beats per minute (BPM). Depending on the game or the level you are building, you might want to select or create your music with the most appropriate BPM value to convey the best emotions.

There are also situations where gameplay will ask for a mix between a higher and lower tempo. This is common in role-playing or action games where players would like to feel they are under tension when they get involved in a sticky situation. For example, it would absolutely break the immersion if your burly, gun-toting player character is hiding behind a cover under heavy enemy fire when classic or chillout music is playing in the background. Likewise, when all is supposed to look calm between two action zones, if the game is playing a piece of high-tempo music, you will needlessly stress...

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Game Development with Blender and Godot
Published in: Sep 2022Publisher: PacktISBN-13: 9781801816021
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Kumsal Obuz

Kumsal Obuz is a self taught, but veteran web developer with more than 15 years of experience in two different countries, leading teams and projects of various sizes. After several years of preparation and transition, he started his own game studio in August 2020. He launched a small puzzle strategy game at the end of 2020 and is currently working on an ambitious farming simulation game. He also likes to mentor, perhaps due to his genetic background since both of his parents are teachers, and because of his love of Godot, founded and still organizes the Godot Toronto Meetup group.
Read more about Kumsal Obuz