Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Best Practices & Getting Started Tutorials

Discussion in 'Input System' started by Fenrisul, Apr 24, 2020.

  1. Fenrisul

    Fenrisul

    Joined:
    Jan 2, 2010
    Posts:
    618
    Decided to make a few of these to help folks that are new, or struggling (as I did) to move from the Old Input Manager to the New Input System.

    Hope these relieve some of the pain!

    PlayerInput - SendMessage


    PlayerInput - UnityEvents


    PlayerInput - C# Events


    InputActionAsset C# Events Without PlayerInput


    InputActionAsset Generate C# Class and GetButton/Up/Down extensions
     
    Last edited: Apr 25, 2020
    Cronoo, avenger_s and lemartialou like this.
  2. DerekSturm263

    DerekSturm263

    Joined:
    Sep 23, 2019
    Posts:
    4
    Hey! How do I read mouse input to get the position of the mouse on the screen?
     
  3. Fenrisul

    Fenrisul

    Joined:
    Jan 2, 2010
    Posts:
    618
  4. NowWeWake

    NowWeWake

    Joined:
    Apr 20, 2020
    Posts:
    4
    Hi Fenrisul!
    That's a subscribe and a like from me.
    Would it be possible to put up brief descriptions for the Youtube videos to help my jump around?
     
  5. Fenrisul

    Fenrisul

    Joined:
    Jan 2, 2010
    Posts:
    618
    Added Part 1 of 2 for Local Multiplayer / couch co-op with gamepads

    *edit*
    You know what...there's some really really ugly behavior when using UnityEvent callbacks here... I'm going to redo this tutorial and file a proper bug report. UnityEvent's are called twice with the same phase for each action... and the Player Join event doesn't consume the event so its extra confusing when your prefab is getting input before it has a chance to run Awake...
     
    Last edited: May 7, 2020
    blackmodjo and Roboserg like this.
  6. UncleAlias

    UncleAlias

    Joined:
    Aug 18, 2017
    Posts:
    27
    Thank you for pointing out that the generated c# class is meant as an alternative to PlayerInput. Other tutorials and guides I've seen make it seem like the former is the way to do c# events with Input System, which ends of being a dead end if you're doing local multiplayer. Also, you can get individual actions and subscribe to them from PlayerInput using FindActionMap and FindAction. (eg. MyPlayerInput.actions.FindActionMap("ActionMapName").FindAction("ActionName") )
     
  7. blackmodjo

    blackmodjo

    Joined:
    May 6, 2014
    Posts:
    14
    Thank you for the tutorials did you try the other options for triggering the joining of a Player and see what happens :D,
    i was supprised to see that till version 1.2 if you wanted the joining to be triggered when a specific button is pressed if you used for example 2 gamepads only the first one would be joined.( on 1.3 it is fixed with 2 gamepads)
    Not to mention that if you use on-screen components and player input nothing works anymore if you wire everything (add the action maps to Playinput, add the multiplayer event system everywhere).
    Somehow these components don't seem to work well together so far and probably because of complexity they are still far away from being ready for production
     
    Last edited: Feb 2, 2022
  8. CTRLRUN

    CTRLRUN

    Joined:
    Dec 4, 2020
    Posts:
    1
    Hi good concise videos. What would be the most performant solution when it comes to input delay/lag?
     
  9. VascoCorreia

    VascoCorreia

    Joined:
    Dec 5, 2020
    Posts:
    23
    Nice videos!
    I watched them all, but is there any way I can spawn players with different prefabs?
    In my current game I have 2 players but each plays as a different character.
     
  10. TravisAlstrand

    TravisAlstrand

    Joined:
    Sep 17, 2022
    Posts:
    1
    You're my hero!