Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Problem with the sample scene for the new input system

Discussion in 'Input System' started by hawkmoon77, Aug 23, 2021.

  1. hawkmoon77

    hawkmoon77

    Joined:
    Aug 11, 2021
    Posts:
    3
    I've been learning how the new input system works. It was going good until I ran into an issue with the "Simple Demo" files that come with the new Input System package. Namely the "SimpleDemo_UsingPlayerInput" Scene.

    I've attempted to duplicate it for hours. But the sample scene is acting differently than my own, even though I'm cutting and pasting the scripts.

    I create my own new scene, I add a player object with the "Player Input" controller, and set the "actions" to the exact same "Input Action Asset" that works in the sample scene. I then add a script module of exactly their script. I set all setting I could find to be the exact same. However, when I run their scene, their controller script gets instantiated and works, and mine does not. I can't figure out what's different between theirs and mine.

    Thank you so much for the help.
     

    Attached Files:

  2. hawkmoon77

    hawkmoon77

    Joined:
    Aug 11, 2021
    Posts:
    3
    Still working on this hours later. I tried something I can't explain...

    Using the samples they gave in the Input System, for "player Input".... I duplicate their script exactly but name it "SimpleController_UsingPlayerInput_Version2". I then swap it out for the original script in their scene. And it does not work. I just can't figure this out. Is there a setting I'm missing?
     
  3. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    Did you hook up the event callbacks? There's an "Events" foldout where the events that are generated by the individual actions (as well as some "bookkeeping" events like OnControlsChanged) need to be told which action to invoke. Without that connection, input will get stuck in within the PlayerInput component.
     
  4. hawkmoon77

    hawkmoon77

    Joined:
    Aug 11, 2021
    Posts:
    3
    Thank you! I figured it must have been a sub, sub menu I was missing. As much as I like menus for building games, I find reading code is a bit more straightforward when learning (for me anyway).

    So this is much clearer to me. It seems that the "player input" controller is the interface for taking the predefined input actions and linking them to a specific function within a specific script. I imagine this is cleaner than looking it sending events everywhere. It also explains why a copy/paste wouldn't work. The functions are the same, but the script is named differently, so the "play input" controller is not sending the events to the newly-named script.

    Thank you very much! I'm going to play with it more.