Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

unregistering action callbacks?

Discussion in 'Input System' started by Dawdlebird, Dec 14, 2021.

  1. Dawdlebird

    Dawdlebird

    Joined:
    Apr 22, 2013
    Posts:
    85
    I register a character to an input (movement in this case)

    Code (CSharp):
    1. controls.CharacterControl.Movement.performed += ctx => player.Move(ctx.ReadValue<Vector2>());
    and when wanting to switch to another controllable character, I unregister the original als follows
    Code (CSharp):
    1. controls.CharacterControl.Movement.performed -= ctx => player.Move(ctx.ReadValue<Vector2>());
    Fairly sure I'm following instructions to the letter here, but the original character keeps responding to input and moving around (in other words; he did not unregister from the callback)... Am I missing something here?
     
  2. Dawdlebird

    Dawdlebird

    Joined:
    Apr 22, 2013
    Posts:
    85