Hello!
I won’t go into much detail about the game just now, as I’m still building the foundation for it, but I’ll showcase what I’ve got so far.
Inventory system
Being a bloodfan of the early resident evil games, I wanted to make an inventory system that resembled its limits, and also taking in some inspiration from “The Last of Us” (mainly limiting the amount of each individual weapon type you can carry).
My plan for the inventory design is a somewhat changing as I’m progressing, but the main style is there.
https://farm4.staticflickr.com/3913/14964541949_c5e7c5ddfa_b.jpg
InventoryDesign
I - somewhat obviously - want it to look like the player is logging all his stuff in a book. Somewhat unrealistic in the way that it would take time to take pictures of his weapons and items and “tape” them into the book, but I like the idea of it.
Inventory Management
For all items and weapons in the inventory as well as the smaller parts of the UI that are always visible, I use a spritesheet to load just one texture into memory. The larger parts have their individual texture loaded.
https://farm4.staticflickr.com/3910/14969904247_1fc075ca9a_b.jpg
T_InventoryItemsSheet
I use that colored grid overlay in photoshop to more easily lookup the column, row and spanning of both. For that purpose, I created a small utility class - “UTIL_TextureSheetManager”. In this class I pass along a the amount of columns and rows as well as the size of the original texture that is in the game content.
UTIL_TextureSheetManager(int32 columns, int32 rows, const FVector2D &sourceSize)
{
_columnCount = columns;
_rowCount = rows;
this->sourceSize = sourceSize;
UpdateScales();
}
...
/*
Columns and rows are zero indexed. Thus the first row and column in the texture is 0
@param int32 column - The column number to get coordinate for.
@param int32 columnSpan - The number of columns the column should span across (i.e: a icon that uses more space horizontally)
@param int32 row - The row number to get coordinate for
@param int32 rowSpan - The number of rows the column should span across (i.e: an icon that uses more space vertically than 1 column)
@return FTextureUV - A struct with the calculated UV coordinates
*/
const FTextureUV GetCoordinates(int32 column, int32 columnSpan, int32 row, int32 rowSpan)
{
FTextureUV uvData;
uvData.U = _singleColScale * column;
uvData.V = _singleRowScale * row;
uvData.UWidth = _singleColScale * columnSpan;
uvData.VHeight = _singleRowScale * rowSpan;
return uvData;
}
...
/*
Updates the scale that represents a single row and column in UV space
*/
void UpdateScales()
{
_singleColScale = (sourceSize.X / _columnCount) / sourceSize.X;
_singleRowScale = (sourceSize.Y / _rowCount) / sourceSize.Y;
}
These are the main important functions of that class for calculating and retrieving the UV coordinates for a column/row in the spritesheet.
In the HUD, I use it like this:
void ARpgHUD::DrawEmptySlot(float x, float y)
{
**FTextureUV uvData = TSM.GetCoordinates(2, 2, 0, 1);** // Lookup colum/row combo in spritesheet
DrawTexture(InventoryItemsSheet,
x,
y,
SlotBgWidth,
SingleSlotHeight,
uvData.U, uvData.V, uvData.UWidth, uvData.VHeight);
}
Items
Items are all part of a base class, and they store their unique information in a struct (FInventoryItemInfo), so I can easily just store that struct data in the actual inventory array. From that info, the game object can easily be spawned back in to the world. I designed it so that I instantiate the base class in Blueprint, and set the info structure there. I find it less tedious than creating all different items through c++.
In that info structure, there is also a sub-structure for defining where this items’ sprite is located in the sheet (also set in blueprint).
So a call to draw that sprite on the HUD is quite simple:
void ARpgHUD::DrawItemSlot(float x, float y, const FInventoryItemInfo itemInfo)
{
FTextureUV uvData = TSM.GetCoordinates(itemInfo.TextureSheetAttributes); // Lookup colum/row combo in spritesheet
DrawTexture(InventoryItemsSheet,
x,
y,
SingleSlotWidth,
SingleSlotHeight,
iconUvs.U, iconUvs.V, iconUvs.UWidth, iconUvs.VHeight);
}
Creating new unique items and weapons in blueprint is also a trivial thing. All item settings like quantity, capacity in stacking, sprite sheet col/row, displayname, description etc. is set there. The “OnPickup”, “OnUse”, “OnEquip” etc events are also implementable there, so each item made in blueprint can easily do different things when used, and the like.
Camera system
To be honest, I also love the good ol’ camera system from the first resident evil games. I made a system like that, with a few extra possibilities like making the camera follow the player (static position, but dynamic rotation).
I have not quite decided yet though… I’m also a fan of regular 3rd person view.
The input for moving the player is relative to the camera position/rotation so it does not feel weird when moving him around. Right is right, up is up, etc. This has caused some problems when transitioning to a camera that is completely different than the previous one. I have to take in to account the button that is being held to move him, after the transition, and not change the relative movement before it has been released. I vaguely remember that that was the case in Resident Evil, i.e.
Here is a video I recorded to demonstrate camera system, current state of the inventory UI and the functionality of the items and weapons creation.
I found a few silly bugs when I recorded, so bear with me
https://www.youtube.com/watch?v=x5-q170jyGE
I’ll post more progress as I go. I’d also welcome feedback and suggestions.
Regards,
Oyvind