Getting to work on the Trader NPC for Bad Luck Black Cat | Blog 2 (8/10/2021)

For the past 2 weeks of the project I have been working on the Trader NPC and learning how UI really works in unreal.

To begin with the Game Designers in our project wanted the mouse cursor to hover over the items in the shop and have the details of that item to show up in a description box. Also when hovering they wanted a box where you could increment and reduce the amount of items you could buy with also having the buy/sell button being active when you hovered over an item.

Designers Sketch

Since it was one of the first times that I have worked with widgets I had never really used buttons before. But thankfully Unreal makes it easy for developers to implement and use buttons in a better way than Unity. When setting up the functionality of the Trader NPC I had to make sure to get a reference of the players inventory and add each item (item icon) to a button that had an image component as a child in the widget. I tried to think of an easy way of looping through all items and adding the icons to the buttons but it proved to be harder to try and loop through an array of buttons with even trying a dictionary. So sadly I had to go through and add sorted icons to the buttons images one by one both for selling and buying. in the future I would very much like to come back to this task maybe on a solo project and figure out how this all could have been avoided.

Next challenge was to add the NPC's Inventory to the Trader Widget. First of all I had to create the inventory for the NPC and have items be added to that inventory. I also realized that it would be helpful for the designers if I had a way for them to add certain items they wanted, but also add a price/value to those items. Another programmer recommended that I should use a data table which would make it easy for the designers to add items with values.

Once I had done the data table and repeat the similar steps I had done for the players inventory to show up in the widget, I had to make sure the player was able to leave the shop which was an easy step. However since I was using the AI Behaviour tree for the trader (like how I was using it for the Questing System) I had to make sure it carried on down the tree so when telling the shop you wanted to exit I had to let the Behaviour tree know too. A the Moment the items that you "buy" don't get added to your inventory but hopefully in the next 2 weeks I will have that implemented.

Current Picture of the trader UI

If you would like to take a look at the Alpha build the link is here:

8 views0 comments

Recent Posts

See All