I’ve created a game feature blueprint. I’ve set a target pawn and which pawn component to add to this pawn.
In the game feature component I’ve added a print node that fires on begin play. It works, the text is printed to log so the system works.
But now I want to add some code to this component and I want that code to start when I click the mouse left button. Or the space key.
But those inputs don’t seem to work when they are inside this component blueprint
This component is attached to the pawn that the user controls and the inputs there work. In theory the pawn receives the input, the attached components should receive them also?
I don’t know how to approach this. Can someone help? Thank You.
If I understood correctly this whole Modular Game Feature idea is to separate code in independent pieces so they can be added and removed with a click and without worrying about breaking something.
I have no idea how to use the input with this type of setup.
If i want to add a piece of code that allows the player to drag something in the scene when clicking with the mouse. So left mouse drags some object. So it needs to know about left click. works if the code is in the player character/pawn
What I need is for this code to be inside the game feature plugin. So it doesn’t react to the input.
Obviously the input needs to be in some place where it doesn’t become a mess. So putting the left mouse button node there may be wrong. but then how to do it?
You put the input in the Pawn and add an interface - if you have many types of comps.
The components implement the interface and decide what that input means to them.
From the Pawn’s point of view, you press Left Mouse and tell the component to Action it.
Each component has a different implementation of said action.
If in doubt, share more details. Are those components spells? Maybe they’re bags of loot, perhaps they’re rocket thrusters or extra appendages of Pawn?
I did not had time to verify this because I had no idea how to work with that setup at the time, I don’t have the project set in that way right now, but I’ve marked the answer as the solution because it appears it does what I was asking for.