Search Unity

disable input temporarly if a variable is true

Discussion in 'Scripting' started by tomcb, May 26, 2017.

  1. tomcb

    tomcb

    Joined:
    Apr 3, 2017
    Posts:
    15
    Hello. Im Using the FPSController in unity and I want to disable input temporarly if a variable is true. How do I do this? I tried putting an if statement under the GetInput() But it still doesnt work. Help? Thanks!
     
  2. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,187
    Show some code probably on how you tried to handle it. But you should be able to just check the bool before your input check happens. If the bool is true, then just return. (you could do an if else also, but setting up the return is easier).
     
  3. tomcb

    tomcb

    Joined:
    Apr 3, 2017
    Posts:
    15
    thats what I did but it doesnt work...
     
  4. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,187
    If you don't show some code (unless you are unable to for some reason) I couldn't tell you why it isn't working. All I can tell you is how it should be handled.
     
  5. cstooch

    cstooch

    Joined:
    Apr 16, 2014
    Posts:
    354
    Like Brathnann said, you need to show code, and are just making people take blind guesses. That isn't helpful at all. If I had to take a stab in the dark, I'd guess that either you aren't setting your bool correctly, or your bool isn't scoped properly (for example, you've declared it in two different functions, each having their own scope, and therefore their own individual values for the bool). Code helps.. use [ code ] tags