"my way" of using the new unity input system

I’ve scoured through the internet for a comfortable way of using the new unity input system and the best tutorial for one (most well explained) I found prior to watching this explanation (given in the argon assault course, hopefully it’s linked correctly to this post) was in a nutshell this (I’m using 1.5.1 btw)
1)Create a new “Player input” component on your player, same one you’d be having your movement script on
2) click on its “create actions…” button and save it as something short like NewControls.
This will add into your assets folder (or other folder if you changed the location) an “input action asset” which has an icon that sort of looks like an unfolded piece of paper with a blue lightning
3) doubleclick to open and you’ll get a menu which’ll likely already have Move, Fire and Look actions set up within an action map called Player but this is where you can make some more maps (which are kind of like folders to hold your actions) and actions, once you’re happy enough with that and you’ve clicked the save asset button within the menu …
4) close it and have it still selected, look in the inspector and tick the “generate c# class” and just apply that, now assuming you named the asset previously NewControls it’ll have generated a NewControls.cs
5) in your movement script you can now use this like so (just an example)

private Vector2 myMovement; 
private NewControls controls;
 private void Awake()
    {
        controls = new NewControls();
    }
private void Update()
    {
        myMovement = controls.Player.Move.ReadValue<Vector2>();
        //set what's being kept in the myMovement vector2  to whatever the action's vector2 is  
        //note "Player" is the action map and "Move" is the action
        Debug.Log(myMovement.x + "  " + myMovement.y);
    }

    private void OnEnable()
    {
        controls.Enable();
    }
    private void OnDisable()
    {
        controls.Disable(); 
    }

Hopefully if someone was stuck because the input system changed this will help, If there’s anyone more experienced with the new input system please do tell me if this is an awful way of doing things as I’m always eager to learn best practices and most performant and/or comfortable solutions.

Similarly if you figured a different way even though you’re unsure if it’s “better” i’d be interested in hearing it :grinning_face_with_smiling_eyes:

Privacy & Terms