Damage VFX on the Player

A Gameobject player, 2 gameobjects with animated sprites showing the spaceship damage, and laser-player script communication.

The first step is pretty simple, create 2 empty gameobjects inside the player and attach them an Animator component with their respective animations

Let’s look at adding some visual effects (VFX) to our game, starting with an explosion that triggers when our enemies are destroyed.

To do so, we are going to want to trigger an animation on the enemy's death.

Like our previous animations, we can simply create a new animation for our enemy, then drag and drop all the sprites. But, if we were to run our game now, the enemy would loop through explosions, we only want this to occur when the enemy is destroyed.

If we go into our Animator window, we will see that our Entry state automatically…

I’ve added another text object that appears within my GameOver function of the UI Manager script. Let’s create some functionality to reset the game.

Firstly, we can create an empty GameObject called GameManager, and have our UI Manager call a method.

In our public method, we can set a bool for is Game Over to be true.

Then within our Update method, we can use an if statement to check if the bool is true AND (&&) for the R key to be pressed. …

Let’s create more UI to better show that it’s Game Over.

Let’s add a Text component to our Canvas, and position it as desired.

We only want this to appear when it’s actually Game Over time, so let’s disable it. Now within our UI Manager script, it’s also good practice to make sure it’s disabled at the start of the game. Let’s create a variable to store the Text object and we can then do the following in our Start method.

The tools in Unity are simple and easy to use and that is one of the most astounding things in Unity!

Today we are going to focus on the built-in features for building your User interface.

What is a User Interface (UI)?

A User Interface is a game or program’s visual display of information to the player.

The most commonly recognized example of a UI is the HUD (Heads Up Display) which is the visual UI elements attached to an overlay over the game’s camera. The HUD affixes certain elements to it such as health/experience bars, menus, dialogue, mini maps, and more.

What is a GUI?

GUI stands for Graphical…

What happens if we have tons of powerup? It would be a complete nightmare in an if statement. Since we have a powerup ID for our powerups, there is a more efficient way to identify objects directly.

We can use a switch statement instead of an if statement.

In the switch statement, we can send in the value we want our switch to verify. Sort these values in separate cases and always end it with a break. …

Modular development is a huge part of software design. Updates, Downloadable Content, Expansions, Sequels, or just continued development of a project will all see the benefit and use of modular systems.

These systems are “Modular” because they are made with the intent to be added onto or changed throughout development in order to fit the needs of the various parts of the project.

So why would anyone want to make a powerup system that is modifiable? Well, that’s easy. What if the developers wanted to add in another powerup later on? Or maybe they find that the powerups you are…

Every powerup should have a limit and we can easily create this limit in code.

Open the Player script and add an IEnumerator. Within this coroutine function, we will switch the bool to false after 5 seconds when active.

Then add a StartCoroutine callup in TripleShotActive().

When we are making a game, one of the key elements is animation. I will show you now how to animate sprites for a 2D game.

This is what our animation will look like:

First, let’s get the first sprite and drag it to our Hierarchy panel. Change the name to “Explosion”.

I am making a game, and it is finally starting to feel like one! I have implemented player movement, enemies, a weapon, and have added art to it.

The state has been achieved after following the replacement procedure of 3d objects to 2D sprites. Along with the graphical changes, a few changes were made in the scripts also that had interaction methods for 3D objects and now it needed a 2D treatment.

So far, the process taught me some of the critical concepts such as vector positions, coroutines, Object tagging, script communication, reference caching, and basic code refactoring.

Ernesto Rocha

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store