Search Unity

Input module

Discussion in 'Getting Started' started by Primoz56, Feb 19, 2020.

  1. Primoz56

    Primoz56

    Joined:
    May 9, 2018
    Posts:
    369
    Hey guys sorry about super obvious question. How do you set up the input module for pc with latest unity? If you could point me to a good tutorial thanks. Googling not helping
     
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    What do you mean by setting it up? It comes set up out of the box, unless you have some need to change it (which you do via the Project Settings menu command). What's the problem you're trying to solve, or task you're trying to accomplish?
     
  3. Primoz56

    Primoz56

    Joined:
    May 9, 2018
    Posts:
    369
    I want to be able to move my character around. I have a blank project and will use a basic cube for a player. How do i make it move in x direction when i press a certain button. I dont see anywhere how to configure say key W to mean forward and how to then hook onto that event to move the box forward?
     
  4. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    You don't "configure" that, you program it.

    You will probably want to spend some time with the tutorials you'll find under the Learn link at the top of this page. But as a quick sketch, you could do something like this: create a new script, give it a name, and attach it to your cube. Then double-click it, and fill in the Update method so it looks like this:

    Code (CSharp):
    1. void Update()
    2. {
    3.     transform.position += transform.forward * Input.GetAxis("Vertical");
    4. }
    Search for each of those terms in the Script Reference to try to figure out how all this works. If it's still not clear, post your questions here, along with your best guess as to what it all means.
     
    Joe-Censored likes this.
  5. Primoz56

    Primoz56

    Joined:
    May 9, 2018
    Posts:
    369
    The way to refernce it made no sense to me and kind of still doesnt. Thanks for the input.getaxis as a point, but how do i infer the input module can be referenced this way, and where would i i figure out if pressing W sets movement forward or if pressing J should do it? Im happy for any code snippets, though a tutorial would be much better.

    I have looked at the script reference for the input manager but couldnt find anything in there apart from very high level details on what it does and how. There was nothing technical about implementation i could see.

    Thanks again for all your help
     
  6. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,141
    JoeStrout likes this.
  7. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    It's a good thing @Ryiah is here. I'm still using the old system and was only vaguely aware that the new one (which is still in "Preview") exists. :)

    And as for how you would know all this, you would know it by either reading the docs, or working through tutorials (which means not just watching them, but actually following along step by step on your own machine). If you think Unity is like a word processor or something where you can just dive in and figure it out without reading the manual... well it's not, and you can't.
     
  8. Primoz56

    Primoz56

    Joined:
    May 9, 2018
    Posts:
    369
    Thank you guys - sorry a bit late :)