Objective: Create an extensible and modular PowerUp System.
Requisites: C# fundamentals. A single PowerUp script that will handle the conditions by ID.
In order to architecture our game decently, we want to create a modular system easily scalable by just adding the new implementation and a new ID.
The first step is creating an int ID variable that will tell wich PowerUP is each one
Objective: Store the difficulty info(int variable) on the Main Menu and pass it to the Game scene.
Requisites: Two scenes and a mechanism to store the difficulty info, in this case pressing a button will make the job. C# fundamentals and Unity PlayerPrefs.
You might be wondering, what is PlayerPrefs? PlayerPrefs is a Unity class that stores Player preferences between game sessions. It can store string, float and integer values into the user’s platform registry.
This sounds very complicated but in a practical way, it allows us to carry on some data between the scenes.
In our main menu script…
Objective: Communicate with other script with the GetComponent function in Unity.
Script communication is a core feature in coding. It allows us to get access to another gameobject’s components or modify external scripts when the variables and methods are public.
For this example, we are going to trigger a public method of our SpawnManager from our Asteroid(when it gets destroyed)
Requisites: An empty GameObject called “SpawnManager” with its spawning implementation and a GameObject Asteroid with its OnTriggerEnter2D method to launch the first wave.
The first step is simple, open the Asteroid script and get the SpawnManager reference.
Objective: After a collision with enemy lasers, add some nice Damage VFX in our spaceship.
Requisites: 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
Objective: Easily loading a scene pressing a button in our Main Menu.
Bonus: Reloading active scene. Exit the application.
Requisites: 2 different scenes, 3 button Canvas setup and a Main Menu script.
One thing every game needs it’s a functional Main Menu. In this tutorial we are going to explore how to load a scene, reload scene and exit our application by using Unity Events. Let’s get into it!
Right click in the hierarchy and create a UI -> Button. A Canvas will appear, create two more buttons inside the Canvas. Let’s give them some fancy names
Objective: Deactivate our TripleShot Power Up after X seconds using a timer a.k.a. Coroutine.
Here we have a videogame where we collect a Power Up and deactivate it after 5 seconds. How was it done? Let’s get into it.
In this article we are not going to dive into the implementation of other features, but if you want to check the Instantiation method, click HERE
When we collect the Power Up, a method is called into the player script by the OnTriggerEnter2D Unity event in our Power Up script that activates the TripleShot and starts the StopsTripleShot Coroutine.
Objective: Create a cooldown system that will restrict our shooting rate in Unity
If you want to check this basic Gameobject instantiation implementation click HERE.
Requisites: A Gameobject Player that instantiates projectiles by pressing a keyboard key, in this tutorial we are going to use the Space key.
In our player script we are going to need a private firing rate variable, in this case the value will be 0.2f.
Objective: Instantiate a moving projectile prefab pressing Space and destroying it when reaching certain position on the Y Axis
If you want to check our Player movement implementation click HERE
Requisites: Player(cube) and player behaviour script, projectile prefab and projectile behaviour script.
First of all we are going to create our projectile, in this case we will choose a 3D object capsule, rename it to Laser and scale it to 0.2 in the XYZ values. Drag it to the Assets folder to convert it to a prefab and delete it from the scene
Important: Instantiating means creating an object clone…
Objective: Implement basic player movement on both vertical and horizontal axes adjustable with a handy private but serialized speed variable visible in the inspector.
Requisites: A Player Gameobject, in this case we will use a Cube and a Player Script
Open the Player script in Visual Studio.
Passionate Unity developer always looking for new challenges!