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:
-
The Actor Owner should bind the action manually on the input component via
InputComponent->BindAction(“Interact”, IE_Pressed,
this->InteractorComponentPointer, &UInteractorComponent::Interact);
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).
-
Pass the InputComponent and the Event name to the component and bind the action on the initialize component
//On InitializeComponent on the interactor
this->InputComponent->BindAction(this->InteractActionName…
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
- I have read that delegates are the way to go but i don’t know how they could be applied here
Any suggestions?
Greetings?