If you have used input that is more complex than simple horizontal/vertical movement, you have struggled assigning button presses to different peripherals. Trying to figure out which axis the right trigger on the PlayStation vs the Xbox controllers was annoying, to say the least.
The ‘new’ input system allows developers to assign the functionality in the code, then setup a control scheme taking in account what forms of input you want to allow.
The first thing we will need is to add the package to our project which can be found under Window > Package Manager > Input System
Grinding your way through a level to accrue enough gold for that shiny new sword, used to standard practice in gaming. It can be time consuming, boring and you may end up with buyer’s remorse only to find yourself grinding it out for something else.
With Unity’s built-in ads, you can offer in-game currency by watching an ad, which in turn, allows you to earn money.
Let’s begin by adding the Advertisement package through the Package Manager:
Using interfaces and abstract classes can be an incredible time saver and helps modularize and decouple your code. So what’s the difference and when should you use each?
In simplest terms, abstract classes can be thought of as partial templates, where interfaces act as a set of rules that classes must abide by. Here’s a simple example of an abstract class:
Interfaces are a great way to modularize or decouple your code. If you look up the definition of an interface, you will likely be greeted with some form of this text:
“An interface is a contract between an object and it’s user…”
So what does this mean? Essentially, an interface is just a collection of method and property declarations that must exist within any class that implements the interface. For example, if an interface has a Health property and is implemented by a Player class, the player class must also have the Health property.
In order to create an interface…
Unity has implemented so many features for 2D game creation that it’s natural to want to make one of your own. In this article, we’ll cover an easy wat to create a hitbox attack system.
The first thing we need to do is to add an empty child object to our player sprite. This way we can animate the collider within the attack animation. We can then add a 2D Box Collider as well as a Rigidbody 2D:
When creating logic for enemy types, it’s common for your enemies to share traits such as Health, Strength, and Attack(). Simple inheritance can be used across your enemy classes to help streamline your code…but what if you want to enforce the use of some methods while allowing them to be customized if necessary?
This is where abstract classes shine! They focus on the accountability of an interface while simultaneously allowing for the flexibility of traditional class inheritance.
Let’s start with a simple enemy class:
Animating tiles in Unity just got easier with Unity’s 2D Tilemap Extras preview package. You no longer need to find the github repo in order to set this up (although the repo still exists for older versions of unity here)
First thing we need to do is to actually add the 2D Tilemap Extras package from the Package Manager:
In order to create this type of game, we will need to implement 2D physics…something that Unity excels at.
The best way to start this project is to create one using Unity’s 2D template: