Ahoy masters of the Unreal.
I have run into a slight problem when coding a designed ‘inventory’ system that is likely a simple problem.
Essentially I am trying to allow players to equip their choice of item to their choice of hand prior to a game. This is easy enough to store the variables and spawn the correct actors to the correct sockets on the player model. I have had no issue getting a character to equip the proper item in the proper hand and I thought all was right in the world.
That was until I equipped a flashlight actor into my character’s hand and realized I had no idea how to control the flashlight from the character blueprint. I worked on the issue, and decided I could ‘Cast’ my custom ‘toggle’ event to the flashlight, and have the flashlight blueprint actors respond by toggling the visibility of the spotlight parented to the flashlight.
Again, I felt like I had solved the biggest problem in the world and life was good.
Until I considered the very design of my solution and the other elements of the inventory choices. My character’s toggle, while coded generic so as to work with any toggle-able item… specifically casts to the ‘flashlight’ actor. So… if I press the button any flashlights in my hands will toggle, but a lighter for instance will not.
I have considered the issue, and decided I need to ‘Cast’ to whatever actors is equipped to the proper socket, which means I need to ‘Get’ currently spawned actor parented to the chosen socket instead of directly referencing the specific equipment item.
The problem is, I am not sure how to do this exactly. Theoretically I can conceive how it could be done, but I am not familiar enough with the options in Unreal or coding in general to know where to start. I seek thine help masters of the Unreal.
The final result I want to have, is left click activates the item in your left hand, right click activates the item in your right hand, and those both activate the proper custom events needed to operate everything from toggled items like flashlights, to one shot go items like a firearm, and holding down for active toggle.
Appreciate the help in advance!
~VGNEVAR