Search Unity

Question Process Events in Fixed Update?

Discussion in 'Input System' started by pastaluego, May 3, 2023.

  1. pastaluego

    pastaluego

    Joined:
    Mar 30, 2017
    Posts:
    196
    Using the New Input System and not the old one, if all my input-based game actions are physics-related and therefore should only trigger actions in FixedUpdate anyway, is there any reason NOT to process input events in fixedupdate?

    The only thing I can think of it negatively affecting is menu input not being as snappy since menu input isn't physics-based, so it might feel laggy if menu input is also running at 60fps.

    It would mean I can never check polled input in Update because it could multipress though right?

    Am I missing something? It's possible I'm not understanding it at all.
     
    Last edited: May 5, 2023
  2. pastaluego

    pastaluego

    Joined:
    Mar 30, 2017
    Posts:
    196
    Are you using the old input system? Because I'm specifically talking about the new Input System that has a mode (Process Events In Fixed Update) that pools input events until the next Fixed Update, so it doesn't have the issue you're talking about that the old input system has (that you could still get around by polling in Update and storing it until FixedUpdate).

    So yeah my question revolves around the new input system.
     
  3. RyanCantCode

    RyanCantCode

    Joined:
    Oct 22, 2018
    Posts:
    8

    Sorry I deleted my post (to repost) before seeing your response lol. Short version, GetKeyDown in Fixed Update can miss, use Update to capture input, use Fixed Update to move the object. If Process Events In Fixed Update can wait till next update I assume that would work too. but I have not tried that yet. I'm in 2021 btw.
     
  4. pastaluego

    pastaluego

    Joined:
    Mar 30, 2017
    Posts:
    196
    No yea I understand that, you're using and talking about the old input system. I'm talking about the new input system (it's a package in the package manager) that is completely different than the one you're used to.
     
  5. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    7,861
    The general principle of polling inputs in Update doesn't really change with the new input system. It still, by default, internally polls input in Update. There is an option to change it to fixed update, but this still provides a less than responsive experience.

    So the rule of thumb hasn't changed. Poll input in Update, act on it in FixedUpdate.
     
  6. TomTheMan59

    TomTheMan59

    Joined:
    Mar 8, 2021
    Posts:
    356
    :confused: Weird, I use this and I never have had an issue with responsiveness. Have you actually tested this?
     
  7. pastaluego

    pastaluego

    Joined:
    Mar 30, 2017
    Posts:
    196
    Isn't the event-based architecture of the new input system specifically designed to be update-independent? I thought that was one of the major reasons behind the redesign.