Introduction:
Today I added a weapon, weapon pickup, and some logic for the game to know which item the player is attempting to pick up.
Weapons:
Although this is an Unreal Engine Third Person project, I was able to choose a generic gun from the Unreal Engine’s built-in First Person default assets profile and attached it to our players right-hand. I positioned the gun mesh so that it looked somewhat realistic in the players right hand. I also added a simple sphere mesh that is used for the projectile that will originate from inside the gun a barrel. I’ll add the actual firing function to the game in a later tutorial.
Weapon Pickups:
Once I had the gun mesh positioned correctly I made a Blueprint version for the item pickup that will appear in the game world. In addition I added some megascan assets from Quixel Bridge to add a little flair to the new level area and to highlight the spot where the weapon will be available for pickup.
Blueprint Logic:
The fun part comes with the Blueprints on the event graph of the player character. I already had the logic for the torch pickup, so now had to introduce the logic for the weapon pickup. This required moving some things around to accommodate for more than 1 type of item the player might encounter. I’m sure there are better ways of setting up these functions and logic (and I have many ideas of making this more reusable while following along this part of the tutorial), but for now I’m following the tutorial’s example.
So now the character blueprint event graph will check to see what item the character has come into contact with and will pick up the appropriate one using the “E” (interact) keybinding. The result is the weapon pickup now appears in the players hand and the item pickup in the world disappears appropriately.
Also worth noting, I know my event graph is messy. I need to set some good habits on organizing my blueprints. Unfortunately the tutorial doesn’t address proper event graph habits, but I’ve seen other videos with some good tips and habits about it.
Conclusion:
In the grand scheme of things I really haven’t done much with blueprints throughout this entire tutorial. I’m looking forward to diving deeper into creating reusable collections of functions and systems to use when I being making my own. I’ve read about the call and respond approach and a few others that I’ll learn about in the future.