Best way to bind input to component?
Hi there guys. Currently i'm trying to modularize all that i can via components for later use, and one of those things that i'm wanting to modularize is the ability to interact with others "interactable" objects.
Right now the component will iterate on every Overlaping actor on the Owner and check whether they implement the IInteractableInterface (if they do or not respond to the Interact message). All goes well until this point but the moment that i press the Interact key ("E" default), i need the InteractorComponent to call the Interact method on itself.
Now my question goes like this, what is the best way to bind the input to that component? I have been thinking on this scenarios:
1) The Actor Owner should bind the action manually on the input component via
But this breaks the advantage of being plug and play, also i would need to know that the Interact method exists on my component (knowing too much of the component).
2) Pass the InputComponent and the Event name to the component and bind the action on the initialize component
I think that this would be good, i only would need to configure the component on creation and it would be set, but a drawback would be that it needs an input component and that breaks modularization a little
3) I have read that delegates are the way to go but i don't know how they could be applied here
asked Jun 16 '16 at 04:53 AM in C++ Programming
Hello, I know the post is old, but I came across your doubt trying to do exactly the same. I was able to solve it as follows.
In the component header:
In the component source:
Follow this question
Once you sign in you will be able to subscribe for any updates here