Question by
taharvinhg · Jun 07, 2021 at 12:11 PM ·
scripting beginnerinputs
How to add / remove function to a Input Action binding via script?
Hey guys, I want to add a function to a binding via script whenever I enter the trigger and remove it when I exit. I use the following code in OnTriggerEnter / -Exit to achieve it.
InputAction.ActionMap.Action.performed += ctx => Function(); //As I enter the Trigger
InputAction.ActionMap.Action.performed -= ctx => Function(); // As I exit the Trigger
However, I can't remove it. It just keeps adding the function to the binding.
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613034713im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Rotate Upperbody to camera direction 0 Answers
Need to Change this script function , please 0 Answers
Making a sword follow mouse movement 1 Answer
Possible Missing XML/DLL Files? 0 Answers