Assigning Input Actions in the Inspector - Unity's New Input System

Поділитися
Вставка
  • Опубліковано 4 жов 2024
  • Assign input actions in the unity inspector using input action reference as part of the new input system. Easily assign hotkeys in the unity inspector.
    Blog Post: onewheelstudio...
    Unnamed Hex Game: itch.io/game/s...
    Support the Channel!
    **********************
    ► Buy me a coffee: www.buymeacoff...
    ► Shop the Unity Asset Store (affiliate): assetstore.uni...
    ► Become A Channel Member: / @onewheelstudio
    ► Or a Patron: / onewheelstudio
    ► My video and streaming kit: kit.co/onewhee...
    ► Buy a Game Design Book: kit.co/onewhee...
    Video Gear List (Amazon Affiliate)
    ***********************************
    ► Sony A6100 Camera: amzn.to/32logXz
    ► Sigma 16mm 1.4 Camera Lens: amzn.to/3KA4Wr4
    ► GoXLR (audio interface): amzn.to/35dmr03
    ► Shure SM7B Mic: amzn.to/3fNbV1E
    ► Blue Mic Arm: amzn.to/3tHgwdQ
    Neewer Light: amzn.to/3rD8eRv
    Light Softbox: amzn.to/3GUaHgQ
    Neewer RGB Light: amzn.to/3rCTQJ9
    Other Links
    ************
    Discord: discord.onewhee...
    Twitter: / onewheelstudio
    Devlog: onewheelstudio...
    Twitch: / onewheelstudio
    Timestamps
    *************
    0:00 Intro
    #GameDevelopment #Unity3D #indiedeveloper

КОМЕНТАРІ • 11

  • @OIndieGabo
    @OIndieGabo Рік тому +12

    Heads Up: the way it is implemented in the video your code will listen to the reference in the map. Meaning it will listen to all devices firing that event.
    If you need to dissociate devices as in local multiplayer or other needs you either handle devices separation or use the InputActionRefence's ID in orther to find its action in an Unity's PlayerInput component. Something like this:
    // Assuming you already have the PlayerInput instance in your code...
    InputAction myAction = _playerInput.actions.FindAction(_inputActionReference.action.id);
    This will find the action wich you are refering to in the PlayerInput and as device pairing is already handled by Unity, you can now listen to "myAction" events instead of listening to the reference, therefore trusting there will always be devices distinction if needed.
    Edit: I was caught up formulating how to express the code piece of the comment and left out the part where I believe this tip is gold. It makes handling inputs way more scalable because it allows to craft handlers for specific actions in a blink. Thanks for the video.

  • @lefoudegaming1233
    @lefoudegaming1233 Рік тому +1

    This tutorial was more helpful than any other, thank you so much !

  • @TheArghnono
    @TheArghnono 10 місяців тому +1

    My google fu almost let me down, but you solved it. The simple piece of code you posted does not require the InputActionReference to be compiled to a c# class - it works just as well whatever way the input action communicates device input to your project.

  • @holmbergen
    @holmbergen Рік тому

    Input rebinding seems to work. I'm using a modified version of InputSystem v1.6.1 Rebinding UI sample (which I've gotten it to work with UI Toolkit with some manual work). I haven't tested local multiplayer but @OIndieGabo seems to be on the right track about that.
    InputActionReferences opens up a lot of my scripts for my singleplayer games where I need to call input functions of completely different GameObjects. Thanks for the vid!

  • @lee1davis1
    @lee1davis1 Рік тому +2

    Down the road, I will eventually start using the new Input System. But until Unity makes the old one obsolete, I'll keep using it.

    • @OneWheelStudio
      @OneWheelStudio  Рік тому

      The new input system is more than a lot of projects need, but I'm curious what's holding you back from adopting the new system?

    • @forbiddenbox
      @forbiddenbox Рік тому

      @@OneWheelStudio personally I find it a bit complicated than just doing a quick Input.GetKey

    • @OneWheelStudio
      @OneWheelStudio  Рік тому

      @@forbiddenbox Fair enough. There is an "easy mode" with the new input system. I've thought to make a video about it for a while, maybe your comment will be the motivation to make it happen :)
      You can do things like:
      if(Mouse.current.leftButton.isPressed)
      {
      }
      or
      if(Keyboard.current.escape.wasPressedThisFrame)
      {
      }
      Not 100% the same, but for quick prototyping it definitely works.

    • @forbiddenbox
      @forbiddenbox Рік тому +1

      @@OneWheelStudio Oh really? well I might start using that then, so that I don't need to install the Input system package after prototyping. You gave me a reason to change to it :D

    • @OneWheelStudio
      @OneWheelStudio  Рік тому +1

      @@forbiddenbox Here's a quick blog post I put together on the topic. Just about to record some video ;)
      Link: onewheelstudio.com/blog/2023/7/4/easy-mode-unitys-new-input-system

  • @OneWheelStudio
    @OneWheelStudio  Рік тому +1

    📰Blog Post: onewheelstudio.com/blog/2023/4/11/dyk-input-action-selection-in-the-inspector-new-input-system
    🕹Unnamed Hex Game: itch.io/game/summary/1462699