[ANDRÉ] Welcome to the third video of the Physics
Playground Prototype Series.
This project is a way for you to get started
experimenting with physics in Unity.
This is part of our Beginner Prototype Series
in which we'll explore creating small projects
focused on game mechanics.
We wanted to create a prototype for players
to experiment with Unity's physics system,
which allows you to create a lot of complex gameplay
with a few simple elements.
In order to do this, we created a camera
that can fly around a playground room
and allow the player to spawn and destroy objects.
Furthermore, we make it possible in a prototype
to change the gravity, freeze the physics of objects at any time,
go into slow-motion mode, and more.
This allows players to really experiment
with a lot of the crazy stuff that you can do
with time and physics in Unity in a fun way.
If you're interested to learn more about how
we managed physics and the game modes,
check out the previous videos linked below.
Here's a quick overview of what we'll look at in this video.
How and why we created a ghost effect
for a spawner object;
how we used the particle systems to emphasize the player actions;
how we used post-processing effects
and changed them depending on the game state;
how we achieved the camera shake effect
to highlight explosions;
and how we managed the audio.
All these topics are part of the polishing phase.
To add polish can mean a lot of different things
when creating a video game, and it is no small task.
In a general sense, it refers to the last effort necessary
to improve a game where the basic mechanics
are already working.
Depending on the discipline you're working in,
when you add polish, you try to make the game
give the player more feedback, make it look better,
and generally take the game from a good state
to a great state.
A good polishing phase is important to enhance
all the tiny details of a project
in order to make it more attractive
and to improve the game's view.
Let's start with a ghost effect on our spawner.
We wanted a way to visually highlight the difference
between an object you're going to spawn and position
and an already placed object.
We decided to do this by using a custom Shader.
Shaders are programs that run on the GPU
and are used to control how we render 2D and 3D objects
on the screen.
A Material specifies one specific Shader to use.
The Shader determines which options are available in the Material.
In general, we use built-in Unity Materials
and Shaders to render our Scene objects.
Sometimes, we need customizations that are not possible with them,
like our ghost effect.
In these cases, a possibility
is to create a custom written Shader,
but since it can be very complex, Unity provides a powerful tool
called Shader Graph.
This feature allows us to create a Shader using pre-built nodes,
without writing any additional code.
We created a Shader Graph to give a bit of transparency to the model
and highlight the edges.
We've also given the possibility
to modify the inner and the border color
and even the thickness of the edges.
During the development, we realized that we needed something
to help understand better the real position of the object
that will be spawned.
In 3D space, perspective can be tricky,
and it's difficult to visualize when one object is above another.
To improve this aspect, we added to the ghost object
a vertical line using a line render component
and a little sphere on the surface below it.
In this way, users have a better sense of depth in the 3D space
and can be more precise when positioning objects.
A very important aspect of games is player feedback.
Helping a player to understand and feel the result of their action
is a big improvement for any type of game.
For example, when a player performs an action,
playing a sound or a visual effect
helps to enhance the feeling of the interaction
and makes the player feel like something has happened.
If we have no clear response to the player's actions,
the player may not understand they have clicked the right thing,
and the prototype feels less good to interact with in general.
This is why we made particle systems
that react visually to the most common operations
that a player performs in the prototype.
Specifically, we made a particle system for the spawn action,
one for the destroy action,
and one for the explosion.
In order to be consistent,
the spawn and destroy particles look similar,
but in the second case, the particles moved inward
enhancing the idea that the object is shrinking and disappearing.
Also, to reinforce this concept,
we added some basic Transform animations.
On spawning, objects seemed to grow from nothing,
enlarging to their final size.
When destroying objects, they shrink until they disappear.
For the explosion, instead, we made a more evident effect
using three different particle systems.
The first one emits particles outward,
and the other two create more evident inner area
that enhances the feel of the explosion.
Speaking of explosion, to exaggerate the effect,
we also shake the camera when it happens.
This is a perfect way to alert the player
that something big is happening in the Scene.
It also makes the explosion feel more impactful and powerful.
We were able to create this effect using the Cinemachine package.
If you're curious about Cinemachine,
in the first video of this series,
we talked about the camera and how we set it up
using this package.
Cinemachine provides useful components
to handle effects like this.
In particular, we added on the Virtual Camera
the Cinemachine Impulse Listener component,
and we attached to the bomb object the Cinemachine Impulse Source.
In this way, when the bomb explodes,
we programmatically send a signal to the camera
telling it to shake.
In the folders of the project,
there is an asset called NoiseSettings
that you can customize to change the shaking effect.
To improve the visual look of the prototype,
we used a Unity package called Post Processing.
This package comes with a lot of pre-built effects
and filters that once applied to the camera
give the possibility to achieve a wide variety of visual styles.
We wanted different looks, one for each physics mode.
We obtained them using two Global Volumes.
A Global Volume doesn't have a boundary
and will be applied to the whole Scene.
In fact, Volumes can also be set up
to affect only a precise area within a Collider.
In this way, you can switch between different visuals
inside a single level.
We used one Global Volume for the physics on-mode
and one for the physics off-mode.
To switch between them, we can change the Weight property
of the volume via script.
A value of 0 means the volume will have no effect,
and a value of 1 means it will have its full effect.
Also, when we modify the gravity or the time scale,
we set some properties within the active Volume
to reflect the new physics mode.
For instance, when we invert the gravity,
we want a sort of extraterrestrial mood,
so we can change the overall color to a blue tint.
And when we activate the slow-motion mode,
we enhance it by desaturating the color of the Scene.
This creates an interesting look,
but it also helps the player to notice
that something has changed in the game world
when they press the button.
Another important key feature added using post-processing
is a Depth Of Field effect.
This effect is used to simulate the focus properties
of a real camera lens.
We added a custom script that allows us
to modify the focus distance dynamically,
based on what's in front of the camera.
This way, when a player aims the camera at an object,
this object is in focus,
and the background behind is blurred.
Sounds and music are really important.
They make a video game unique and improve the mechanics,
giving the possibility to express new meanings.
♪ [MUSIC] ♪ Audio is often underrated,
but it is as important as the rest of the game,
and the player will immediately notice its absence.
To add audio and music to the prototype,
we created a script called Audio Controller
that is able to control the settings of our Audio Mixer.
An Audio Mixer is an object that allows you to mix
various audio signals dynamically
and apply effects to them in real-time.
We prepared three different audio sources:
a background music source,
♪ [MUSIC] ♪
a reversed background music source,
♪ [MUSIC] ♪
and a single note random clip source.
♪ [SINGLE NOTE] ♪
When the game starts, we play the normal background music,
and we also keep it during the physics off-mode.
But to really emphasize this mode,
we'll reduce the high frequencies in the music,
using a low-pass filter to give the Scene a softer feel.
When we switch into the inverted gravity mode,
we fade into a reversed version of the background music.
This also makes clear the idea
that something out of the ordinary is happening
and a change has taken place.
If the active mode is changed to slow motion,
we lower the pitch of the active audio source by half,
giving the player the idea that time has slowed down.
Controlling the Audio Mixer with our script
allows us to mix between these different effects
while the game is running.
The last feature we added is whenever the player spawns
or destroys an object, we play a sound.
Each time the player takes one of these actions,
we play a random clip that contains a single note
from the background music.
If the player is spawning an object,
we pick a random audio clip, playing forward.
If they are destroying an object,
we select a random reversed audio clip.
This is very useful to inform the player
that his action has completed successfully,
improving overall feedback
and differentiating between the two actions.
Thank you for checking out the Physics Playground Prototype.
The whole prototype is available to download for free
via the link in the description below.
We have also recorded a longer workshop video
that is published on our Unity Learn site
where we'll explore project in greater detail.
You can find a link to that in the description as well.
Hopefully, this series has given you some ideas
for how to use these tools and techniques in your own games.
Thanks for watching!
♪ [MUSIC] ♪