Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Player Input Component

Discussion in 'Input System' started by jackieucla, Aug 1, 2020.

?

Are there enough tutorials to show how to actually implement the new input system in a game?

  1. Yes

    1 vote(s)
    20.0%
  2. No

    1 vote(s)
    20.0%
  3. No way not even close

    3 vote(s)
    60.0%
  1. jackieucla

    jackieucla

    Joined:
    Mar 30, 2020
    Posts:
    2
    Can someone please help clarify - if I am using the Player Input component are these OnEnable and OnDisable still necessary or is the Player Input basically taking care of it now?

    Code (CSharp):
    1.         private void OnEnable()
    2.         {
    3.             _inputActions.Enable();
    4.             _inputActions.Player.Interact.performed += OnInteractButton;
    5.         }
    6.         private void OnDisable()
    7.         {
    8.             _inputActions.Player.Interact.performed -= OnInteractButton;
    9.             _inputActions.Disable();
    10.         }

    upload_2020-7-31_23-31-54.png

    Presumably the Movement InputAction is similar to this interact script below and this is all I need for the Player Input above to work

    Code (CSharp):
    1.         public void OnInteractButton(InputAction.CallbackContext context)
    2.         {
    3. //Do whatever interaction
    4.            
    5.         }
    [/ICODE]

    Thanks
     
  2. FamousJoshua

    FamousJoshua

    Joined:
    Feb 20, 2016
    Posts:
    4
    As far as I recall with the component you don't have to do any set up scripting at all. Just set up the Unity Events like you have there and that should work as advertised.
     
unityunity