Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved Updating/Triggering Actions without Inputs?

Discussion in 'Input System' started by ricky_lee_, Jan 31, 2021.

  1. ricky_lee_

    ricky_lee_

    Joined:
    Jan 31, 2021
    Posts:
    5
    Using the new input system and I'm having a problem finding a solution in the documentation, though I think its probably easy for anyone who isn't a noob like me, so I thought I'd ask.


    My "Movement" action simply updates a Vector2 called "InputXY" using the InputAction.CallbackContext, and my character moves using InputXY in a fixed update.

    upload_2021-1-31_17-15-45.png

    Code (CSharp):
    1.     public void Movement(InputAction.CallbackContext context)
    2.     {
    3.         inputXY = context.ReadValue<Vector2>();
    4.     }
    But when I pause using Time.timeScale = 0f my InputXY value cannot change. So when resuming, InputXY is what it was at the point of pausing - causing you to walk without any input, until you give a new input.

    Is it possible to get a "currentContext" of the action/inputs so I could manually run the "Movement(InputAction.CallbackContext context)" method?
    ex;
    Code (CSharp):
    1.     public void Resume()
    2.     {
    3.         Time.timeScale = 1f;
    4.  
    5.         Movement( PlayerControlMap.Movement.currentContext );
    6.     }
    Or maybe a way to false trigger my action without any input?
    ex;
    Code (CSharp):
    1.     public void Resume()
    2.     {
    3.         Time.timeScale = 1f;
    4.  
    5.         PlayerControlMap.Movement.trigger;
    6.     }
    Thank you for taking your time to help a noob :S
     
  2. ricky_lee_

    ricky_lee_

    Joined:
    Jan 31, 2021
    Posts:
    5
    Thanks to everyone who looked

    I've solved my issue.
     
  3. babaqalex

    babaqalex

    Joined:
    Jan 28, 2016
    Posts:
    17
    do you mind to share how you solve this? I am trying to figure out how to false trigger an action without the actual input.