Unbind action in C++

Hello,

I have a simple question but I cannot find the answer anywhere. I am wondering how to unbind an action input during runtime in C++.

I am currently using the simple way to bind inputs:

 InputComponent->BindAction("MoveForward", IE_Pressed, this, &ACharacter::MoveForward);

but I want, at any moment disable this binding.

Thanks :slight_smile:

Hello FG707,

Iā€™m not sure if this is possible to do, but what are you trying to accomplish by doing this? I may know of another way to do it that doesnā€™t involve unbinding this action.

Hi ,

I would like to enter a Trigger Volume, enable only one action (Interact) by pressing the ā€˜eā€™ key. After having Interacted with this Trigger Volume, i want to disable this ā€˜eā€™ key and enable the ā€˜vā€™ key to do another action (Evolving) and the ā€˜bā€™ key (Back).

In general, I would like to have a character ā€˜zoneā€™ state, and a set of keys associated to those states. For example:

  • InZone - ā€˜eā€™
  • Interacted - ā€˜vā€™, ā€˜bā€™
  • Evolving - ā€˜bā€™

Right now, Iā€™m using booleans to achieve this, but I would like to bind and unbind keys instead.

Thanks!

I would personally use booleans and/or a setup using Overlapping Actors from the Trigger Volume but it seems like this will be possible for you. Youā€™ll need to get a reference to the InputComponent from where you set it up and then call the function entitled ā€œRemoveActionBindingā€ and enter the index for which binding you wish to remove.

For future reference, the way I found this out was with the help of Visual Assist X (built-in Intellisense would work as well) for Visual Studio. I loaded up a C++ project based off the ThirdPersonCharacter template and had a look at the SetupPlayerInputComponent function to look through the available functions for the UInputComponent pointer being used. Looking through existing code to find things like this can be very helpful when you have a vague idea of where the functionality you want may be.

Hope this helps!