Rapid prototyping is the first step on this, let’s name it “Road of the Development” to keep RPG theme, and its purpose is straightforward. Implement basic functions as quick as possible. Polished, fancy looking 3D assets are far away at this stage. So first step is to implement main character. Changing armors and weapons is inseparable part of RPG themed games. To allow player dress hero to their taste. “I’m in a good mood today, I want to be a paladin that help others in these hard times.”, “My boss has really pissed me off today, I’m gonna wear dark steel armor and smash everyone I’ll meet during my journey today!” and so on… Implementation of such a system depends on ones experience and knowledge, as well as preference. I’ve decided to use segmented meshes to avoid, or at least minimize, clipping issues with meshes (). Function logic is simple, just switch meshes when new armor or weapon is equipped. For rapid prototyping purpose, I’ve decided to use mannequin which is included in UE4 Engine. Once it is properly set up, one just need to swap meshes for finished assets and it should work.
Base character setup is basically done. Next step is to create some assets, like helmet, armor, weapon, and test how it works. But first let’s talk about what in-game object is. Disregard 3D mesh now, and let’s talk about in-game object itself. Let’s say, piece of breastplate. It not only holds information about what 3D mesh has to be loaded and rendered, it also holds other variables as well. Object class, armor value, weight of armor, basically whatever variable you want it to contain. So we can say that in-game object is basically a collection of variables, where each variable carry some information about object. So what we want to do now, is basically create structure of variables we want to use for in-game objects. In UE4 it is called simply “Structure”. Inside structure file you can add as many variables as you wish. My structure file looks like this.
I’m thinking about adding a crafting system at alater stages as well, so I’ve decided to add “recipeIndex” variable for later use. Still trying to come up with new game mechanics that could be add to the game, but need to set up basic functions first. Collider added to actor component detects collision with player character , allowing player to interact with object, using simple bool check that is switched to true/false using onCollisionEnter/onCollisionExit. Inventory system works basically as described on image above. If object enter collision with player character, player can interact with said object. Above mentioned variables are then moved from game world to inventory slot and actor is deleted from the world. For this purpose, we need to add few more variables to player character. Variable that holds information about item, array that holds information about all items in inventory, and I’m also gonna add integer variable that defines inventory size. “inventorySize” variable will allow me to modify player’s inventory capacity at later stage, let’s say, through unlocking required skill in skill tree, or wearing armour that allows player to carry more items…etc. I’m not going to implement that mechanics righ now, but it is good idea to think forward. The key (at least in my opinion), is basic logical thinking. What I want object to do on interaction? What actors/objects depend on this function/variable? Sometimes it helps me to simply use power point and visualise what I want to do in logical order.
This simple function should move item from world to inventory. But inventory does exist only on blueprint level for now, so next step should be to create invenotry UI. For this purpose I’m going to create simple inventory window and populate it with buttons. Buttons allows us to detect collision with mouse cursor, change appearance on click on button, on “mouse over”…etc. (this also gave me an idea of another game mechanic I can implement later. That’s where notepad comes handy.). Now, “inventorySize” variable from player character comes handy. “inventorySize” basically defines how many slots will be in inventory. Simple logical function described above should now move item from world to inventory.
Picking items should work now. I’m not going to create fancy inventory slots and icons for items at this stage. There’s simply no reason to waste a time on creating fancy graphics just to find out that inventory system is broken. Creation of detailed, polished assets and graphics is still far away. Nice looking, but broken game is still a broken game. Still need to implement function that will increment item position in inventory if slot is already taken. Simple check should do the job. Since picking object will transfer all variables from the object to inventory, we can check if slot contains object of any class. If there’s object of any class in the slot, it will simply increment position of item in inventory.
So let’s drop some test objects to the game world and pick them up.
So that’s picking objects done for now. I’m going to add few more variables to the player character before embarking for nightsfit again and will continue later (got 3 days off after this shift, wohooo). I’m gona add float variables for health and stamina, and since it is going to be fantasy themed game with RPG elements, I’m going to add variables like armour type, enemy type, weapon type…etc.
So that’s me done for today, just going to put some footnotes here and that’s it.
World map – creating inventory window using buttons has given me an idea of world map and functions related to travelling. Populate world map with invisible buttons that will execute different checks on collision with player’s icon traveling through the world map.
- Locations – Reveal location on world map on button collision with player icon
- Hidden locations – on button collision with player icon, get “perception” variable from player and perform roll to reveal hidden location (i.e. player’s perception = 10, get random integer in range of 0 – 100. If player’s perception => random integer, location is revealed on the map)
- Secret locations – perform same roll as above, but only if player has certain skill unlocked. (possibility of use of easter eggs?).
Need to test it first. But at a later stage, after other, more important mechanics are implemented. I’m just going to leave it here for now, and will return back to it later.