In getting the inventory working, I have run into an, up to now, insurrmountable problem getting the sword (currently the only weapon) to attach to the players hand. This has prevented me from getting the game to a state where it could be released for even the first stages of testing (since the ability to know you have something equipped is rather important to being able to play the game; and also other parts of the code weren’t recognising it correctly, so you couldn’t attack the slime).
After much searching, watching turotials, and reading help sites, I initially developed this blueprint to sort and attach equipment from the inventory to the player:
While this did not work as expected – the weapon moved from the right page of the inventory menu to the weapon slot on the left side. but returning to the main screen showed the player still unarmed – by adding print statements at various points, I was able to show that the current weapon was being returned as “sword” and all indications were that the “Add Static Mesh Component” and “AttachToComponent” commands were working.
After eight to ten hours searching for a solution, I added a “Set Sword Added” command and discovered that I could now attack an enemy with what was essentially an invisible sword. As the equipping is driven from the inventory, this time is included in the inventory section of the plans.
Having checked that the attack code was still operating correctly, I then modified the blueprint, adding a “blank” static mesh (attached to the right hand socket of the player character skeleton), and using a Set Static Mesh command to change its appearance to the sword when it was equipped from the inventory.
Then in the sword’s use item blueprint I added the following, so that the variable required for the attacking code to work was set correctly:
While this might not be the most elegant piece of coding, it is a work-around that lets me get a working demo up and running.
Today I also:
- Got music playing when in menu and bulletin board screens – i.e. when the game is paused.
- Fixed an issue where casting between the player and the instance would not work correctly when you started gameplay from the main menu rather than the town level.