Monday, April 27, 2015

Big Game Project, Week 3 - Serialisation and Character Selection

Hi,

This week has been about finishing up the character selection (the programming part) and figuring out how to save and load a game since we will be able to unlock characters we kill in our game so we needed some way to track that as well as all the regular data that needs to be saved like stats on your character and such.


Now the player can choose a character, click the new game button and can then add a name and press play to play as that character.




The game saves the selection and name for the next time the game is played. When the player returns he or she can choose to continue with the saved character or press the new game button.



If the player unlocks a new character in the game it will be available in the menu like this gnome character below. Here you can see that no name is displayed and only the New Game Button is available.



There is quite a lot of code that goes in behind all this...or should I say visual code perhaps since all is done using Unreal's Blueprints. I won't go into all that but I will mention the saving part of this.

First I created a SaveGameObject that holds all the data that needs to be saved. I then added code in our Gamemode Blueprint that handles loading and saving to and from this SaveGameObject.

The first step the GameMode does in it's "Begin Play" Event is checking if a save game file exists on the computer by calling the below function. If it doesn't it creates a SaveGameObject that will use my SavegameObjects data and then save and load that to file. So Unreal has built in functionality for this.

So first "Does Save Game Exists" is called. If a save game file exist it calls "Load Game From Slot" and cast it and set that to my SaveGameObject I created. If it doesn't it calls "Create Save Game Object" and cast it and set it to my SaveGameObject . After that I "Save Game To Slot" to actually save the game to file so I have it there for next time even if no info is added at this point.


 

Then I have two functions called LoadData and SaveData that basically works similar to the picture above but only do just what the name implies.

Here is a link to Unreal's documentation on the matter: https://docs.unrealengine.com/latest/INT/Gameplay/SaveGame/Blueprints/index.html

A note. I have had some problems with saving data into my SaveGameObject before the actual save is made so I have gotten some strange results and I highly recommend using breakpoints and Print string functions so you see for sure that all data is saved and loaded correctly.

The trouble I had was adding an array of an Actor component to the SaveGameObject which didn't work too well since my SaveGameObject is not an Actor, at least I think that was the problem. I couldn't access the contents of the Actor components so in the end I replaced that with an array of a Blueprint structure to hold all my data instead. It works much better now but its a bit tedious with the structure to access its members and setting them but it works.

If you have any question regarding saving and loading using Unreal's Blueprints feel free to ask by writing a comment.

Friday, April 17, 2015

Big Game Project, Week 2 - GUI

Hi, New week == new blog post.

At the beginning of this week I migrated all the gui stuff I did previous week into the real project. I had to do some tweaks here and there to make it all come together.

I added functionality in most the gui objects so they hold an image behind all buttons and stuff. So when our talented graphical artists have time to make textures and nice art to the gui I can just slap it on there. As you can see in the picture below I added a Character Panel this week with all the stats.

(All the art you so in all the screenshots are placeholders so its not from the final game.)


(closeup of the character panel)

So in a design perspective I have tested different locations for all the gui elements because I want to design it all so it will be minimalistic so the players main focus will be on the actual environment of the game but its hard to test until we have a playable game.

The Character panel and the inventory can be moved outside the screen. I added a "C" and an "I" on them to show the players how to open them because they will start hidden like the picture below.
When the player either press them with the mouse or with the keyboard they animate out to their final position.

(the black borders on the sides will not be there in game. not sure why they show up sometimes)

I also added so that when you mouse over an object it will show what it is and when you stand close to it you get a different text. This is to let the player know that he can do something with a certain object. Se the text "Stone" and "Pick up Stone" below.



In the middle of the week I used about a day to learn about Unreal's Navmesh navigation system. And I found out that its fairly easy. The only thing I had major problems with was when the character was walking in a certain direction he was looking at the final target and not in the walking direction. To fix this I started out with making stuff rotate left and right to get it right but then found a very easy way to do it. Just set so the character orient its rotation to movement.....Done!
It took med 3 hours and it could have taken just a few seconds if I would have known this one.




And lastly I started working on the start and option menu. We will have a menu were you can choose all the monsters you have defeated and then chose to play as them. This is the start screen with some buttons, Nothing much right now but its work in progress


When you click new game you will be able to play all unlocked characters. You will select them by scrolling them in a circle or something similar.  Below is a screenshot of an idea of how it might look.



If you have any questions of how I did a certain thing please leave a comment below and I will try to answer it as soon as possible.



Sunday, April 12, 2015

Big Game Project, Week 1

This is the first week of the production of a game for our class Big Game Project.
I'm in a group with three other people, Two graphical artists and one other programmer.
I will have the role of a programmer and I chose to not take a lead role in this project so I could focus more on production and learning. The game we make will be a dungeoun crawler with a camera view similar to that of Diablo 2. The motto of the game is play what you kill. So basiclly if you kill an NPC you are allowed to play as that character. The game will be made with Unreal Engine 4.

I have spent this first week to learn the layout of the unreal engine and focusing on working with Unreal's Blueprints. Blueprints is a visual programming tool and you can make a complete game with it without writing a line of code.



How it works is this, It starts of with an event node (Red on screen) or a function node. And from that you draw a white line that is the execution line and then make a new node that does something.
For example. The red node above "Event Begin Play" is run once when the game starts and then the white line goes to "Create PickupText widget" wich creates a component to handle text to the screen in this case.

Everything that follow the white line will be done in that order. I must say it takes some time to grasp all elements in blueprints but there are many helpful tutorials from Unreal and from the community to get you started.

This week I have been focused on lerning the basics of this system while creating a HUD and some GUI elements like an inventory. Here is a screenshot:



In it you see two bars, Health and Speed they don't do anything at this moment other then the visual.
I also created a pill object with a floating text that you can pick up into your inventory.
While in the inventory you can choose to use / consume the pill, drop it or cancel the action.

Next week I will try to migrate some of this into our real project and create some other components for our game.