Hey, hey, it’s Tamara here! This is the first video tutorial on how to make a HayDay clone. In this episode you will see how the game functions in general, get an overview of what is going to be in the series and even take first steps: we will set up a project together in Unity and make a robust currency system and experience system.
To begin with, let me tell you about this new series I am starting. I know that a lot of people love HayDay and similar farming games. I was one of them at the time when I was extensively playing such games.
In fact, they have inspired me to make my own game Lost in Athilidus. By the way, if you want to know how the game is doing now, you can watch my devlog series. Making this game got me thinking about everyone else, who has an idea and wants to bring it to life but doesn’t know how.
In addition, one of my subscribers suggested it under my video. I read all your comments and take your feedback seriously. Thank you for writing them.
Also, I have a discord server where you can make suggestions about the future videos. Unfortunately, there are no good tutorials on how to make a game like this. And since I’ve already gone through the whole process of development – I can help you make your own game.
By the end of this series you will have a finished project with main mechanics that you can see in the game. We will cover stuff like building things, planting crops, taking care of animals, baking things and many more. After completing this series, you will have a prototype that you can expand further by adding more buildings and products.
After each video there will be a project available on my patreon. This will be a great way for you to support me so I can continue making these videos for you. Of course, you get even more benefits when you decide to become a member, this is just one of them.
Now, I’d like to look at the basics of HayDay game setup. I found a video of the gameplay that I will use to break down the most crucial things this game has. They are shown in the tutorial at the beginning of the game.
I left a link to the original video in the description. Before we start, let me just remind you to subscribe to my channel and turn the notifications on to not miss out on my new videos. And let’s get to the video.
The first thing we see in the game is a slideshow which tells you a backstory. Your uncle left you this farm because he’s retiring. This is a pretty common scenario of getting a land.
I’ve seen similar ones in other games, it just has some variations to it like who has left the land and what is on that land. Anyway, you’ve become a farmer by watching these slides. If you’re wondering how to make this part – it’s just UI images which have an effect of gradually disappearing.
A tweening engine can do that easily. Some games might use a 3D video instead of a slideshow. Then we see a loading screen.
This is when the game connects to the internet and initializes things. If you have already played the game this is the place where it loads everything. The first thing we are taught to do here is planting and harvesting – this will be later on in my series.
I made this mechanic for my game LiA in one of the latest devlogs. Crops take time to grow. I have already made a tutorial on this topic so if you’re very eager to finish your game even before the series feature this tutorial – you can check this video out.
But in the series, I will show an improved version. After this, the player has to repair these buildings. I also have a tutorial of a grid building system but in HayDay it is a little bit different.
It doesn’t have a visible grid underneath it. However, you can still notice that buildings snap to it. To get buildings you would have to go the game shop.
This shop is not like in other games when you click on something and you get a building placed on the map. In HayDay you have to drag your object onto the map from the shop. It might be confusing because you actually have to combine UI elements with game objects.
Now, let’s set up the project. First of all, we have to figure out what type of isometric game it is. I made a video on this topic about three different ways to make an isometric game.
It features a classic 2D view where everything is drawn isometric. This is clearly seen from character animations – they are all not so smooth as they would be in 3D. Also, car animation is pretty revealing.
For convenience, we will add an isometric grid. This can be later used for object snapping but now it’s helpful for visualization. The project is empty so the first thing we should do is add background.
One option is to draw a large isometric background with terrain elements. This way is good when you have a lot of various element that look different. But in in our case we can certainly use large chunks of background as tiles.
Notice, this isometric game uses a 2:1 ratio as it is usually done in games and not the standard isometric view that you can find in engineering drawings. Pay attention to this when you make the graphics for your game. Everything that is going to be clickable we will make into a game object with a script so when making a background, add only the elements that the player will not interact with.
However, if you’re making some kind of city where every building is going to be static you can just add game objects with colliders above them and treat them as it was a building. In the game, we have seen a lot of movement which certainly adds life to the game. Flying butterflies, swinging trees, smoke coming from the main house and, of course, the characters.
I can’t show you how exactly to do these things because they are mostly done on the art side of the project but I can explain how they done. Considering that the animations are 2D you have two option here: make frame by frame animations and make rigged animations. I would choose frame by frame for simpler things like those butterflies and rigged for characters.
Also, I will have a separate video in this series where I will be talking about character AI. Since this is just the beginning of our project we will start with the basics – Currency system and Level system. But for these we will need an EventManager.
I once found a good one for Unity and now I use it in my games. I will leave a link to it in the description. You’ll see how I use it soon.
You will need only the EventManager script so go ahead and copy it. ----------------------------------------------------- I have set up the UI and now it’s time to write some code. First, we will take care of events.
Create a script called GameEvent. This is an abstract base class for all our events. For now, we will just need 5 of them: Currency change event – when we get or spend some; Not enough currency and enough currency – to get response from the currency system if we have enough money to buy something; Xp added game event to notify the level system when we get some experience; And level changed game event to unlock things from the shop, production items etc.
when we achieve a new level. Some of these events have fields to pass information like currency or the amount of experience we got. [Currency type is an enum – write this in the video] After you’re done with this script, we can move on to the others.
Create 3 scripts – CurrencySystem, LevelSystem and GameManager. Open them in the editor. We will start with a CurrencySystem.
First of all, create an enum to store the types of currency. In HayDay you have two main currencies: Coins and Crystals. Then, in the system class, create a dictionary to store all our treasures.
Then, we will have a list of objects for UI initialization – currency texts. After this, create a dictionary for these texts. This will make the usage of them easier.
In the Awake method, initialize the dictionary. Next, we have to make this class listen to events CurrencyChange and NotEnoughCurrency. Create methods for this.
Currency change method is going to accept event information of this event. We will add the amount we receive to the value from dictionary. Notice, that if we buy something the amount will just be negative and everything will still work.
And update the currency text here. As for the not enough currency method, we will just print out a message in debug. In your game, you can display a window for this.
Subscribe these methods to the events in the start method. We have finished the Currency system, so now, open LevelSystem script. Create the most important fields – current XP amount, Level and xp left to next level.
Then, create two GameObject field to store UI panel with level info and a new level window prefab. After this, create a bunch of private fields to store things like level text, xp slider etc. Also, we will need to store levels XP and rewards.
Create a static bool initialized and two static dictionaries xpToNextLevel and LevelReward. That’s all with the fields, moving on to the methods. In the Awake we initialize all those UI fields (you can do it your way since this part of the game can look a bit different for everyone), then if the bool initialized is not true, we call an initialize method which we will create soon.
And we also have to get the xp to next level so we try to get a value from dictionary. I will show you an example how to initialize xp and reward dictionaries from a csv file but you can do it your own way if you don’t know how to work with such files. Basically, what we do here is load a file and read it line by line.
Then, from these lines we get values and store them in our dictionaries. Ctreate a method to update UI. In it, set the slider fill value and xp left text.
Now, create two methods OnXPAdded and OnLevelChanged. In the first one, we accept event information as a parameter. We add the xp amount we received and update UI.
Also, here we will check if a new level can be reached. If yes, we increment the level and invoke an event. In the second method, we reset the current xp by subtracting xp to next level from current xp and get a new value for xp to next level.
Set the level text. After this, instantiate a new level window. I set the parent of this window our canvas which we get from the game manager.
We will get to that later. You can do the reward initialization here but to make things simple I made a very basic window with just a close button. I initialize it after this.
It will destroy the window. Next, invoke the events to add rewards. Create a new currency change event and pass the info about reward.
Call event manager instance to queue event and pass the info. Do the same for the crystals. Create Start method.
In it, subscribe methods that we just created to events. And also, update the ui. When we implement a saving system this will be the place to load values.
That’s all for this script. Now, open the game manager. First, create a static variable GameManager current to make it a singletone.
We need another field for our main canvas. In the Awake method, initialize current field with this. Now, we have to create two methods just for testing.
One to get XP and one to get coins. These are simple methods in which we will just invoke corresponding events. Now, it’s time to connect everything to our game.
Go back to the editor. Create GameManager, add script to it and initialize its fields. Repeat the same steps for EventManager, CurrencySystem and LevelSystem.
Also, connect test buttons. Now, if you made the initialization of new level rewards and xp using csv file, don’t forget to create it. You can create it using excel.
Just save the file as csv. Now, when you fill it in, first row is for titles, then you can start typing in the values. First goes the level, then experience to next level and then two rewards – coins and crystals.
Now, you can test if everything works. This was everything for this episode. I hope you enjoyed my explanation of HayDay.
I want to encourage you to make original games and not just HayDay clones. The mechanics that will be shown in this series are pretty common and there is a huge competition out there. But if you put your great idea into this type of game, add interesting characters, animals and plants – you can make an original piece.
And you don’t have to stop there. I want you to take this project base and build up on it. Maybe, you can invent a new mechanic.
Anyway, I hope you will learn a lot from this series about making a simulation game in Unity. I want to remind you that you can support me on Patreon and get the project files for HayDay. Thank you for watching!
Don’t forget to subscribe to my channel and turn the notifications on. See you soon. Byeee!