Search Unity

{Input.GetAxis("Vertical")=1;}

Discussion in 'Scripting' started by sheva, Apr 18, 2011.

  1. sheva

    sheva

    Joined:
    Nov 22, 2010
    Posts:
    157
    Hi guys, I've a question.
    I'd want to make a button that press automatically GetAxis.
    How can I made a script like this:
    Code (csharp):
    1.  
    2.  if(Input.GetButton("anybutton")) {Input.GetAxis("Vertical")=1;}
    3.  
    Thanks, Nik.
     
    Last edited: Apr 18, 2011
  2. hallamasch

    hallamasch

    Joined:
    Nov 29, 2010
    Posts:
    153
  3. sheva

    sheva

    Joined:
    Nov 22, 2010
    Posts:
    157
    Ok, but how can I define Inpu.GetAxis always = 1 (true / pressed) while i'm pressed another button?
     
  4. hallamasch

    hallamasch

    Joined:
    Nov 29, 2010
    Posts:
    153
    Please have a look at the documentation, and than clarify your question.

    Thanks
     
  5. sheva

    sheva

    Joined:
    Nov 22, 2010
    Posts:
    157
    Is there any function that can press the button automatically with a script instead i pressed it by myself?
    For example:
    if(input.GetButton("G")) {press the button "Fire1" automatically (fire is pressed) }
     
  6. TheRaider

    TheRaider

    Joined:
    Dec 5, 2010
    Posts:
    2,250
    you use and or (||) statement in your if you statement for task is the easiest way.
     
  7. raybarrera

    raybarrera

    Joined:
    Nov 20, 2010
    Posts:
    207
    I'm not sure of a way to do specifically what you're saying, but my first instinct would be to by pass the firing button bit and skip to the function the fire button calls.
     
  8. TeckDeveloper

    TeckDeveloper

    Joined:
    Apr 14, 2011
    Posts:
    38

    Nevermind, I now see what you are saying, and I dont know of anything like that.
     
  9. TheRaider

    TheRaider

    Joined:
    Dec 5, 2010
    Posts:
    2,250
    if(buttonPress || Input.GetAxis ("Vertical") >0)
    // do whatever

    then just make buttonPress a boolean and set it to true while the button is being pressed and return it to false when it isn't.