Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

Issue with script from Unity Wiki..

Discussion in 'Scripting' started by TreasureChestMimic, Jan 26, 2018.

  1. TreasureChestMimic

    TreasureChestMimic

    Joined:
    Jan 26, 2018
    Posts:
    8
    I'm pretty new to this whole thing, so thanks for any help you guys can provide.
    I was using the script from the wiki (http://wiki.unity3d.com/index.php?title=KeyCombo) in order to create simple inputs turning into action X. This script seemed great as it had the check function in it which I was using to determine if pressing Fire1 would perform the regular or keycombo action.

    First, I tried the input for down + right, and everything worked as I had hoped.

    Then I tried to do down + left, only to have the keycombo action take effect even though left hadn't been pressed. I was confused, so I ran it back and removed the "down" all together, and I STILL got the move when I pressed down. When I removed the second move, everything went back to normal (ie not doing the move when "down' was pressed, still getting the move correctly when "down", "right" was pressed).

    As I said this whole thing is new to me, but for the most part it's all been pretty logical. This on the otherhand is blowing my mind. Could anyone explain why this is happening? Any tips for resolving it would be greatly appreciated too!

    Thanks in advanced guys!
     
  2. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    oh my goodness lol. Just spent at least 10-15 minutes on this :)
    For a while I was just playing around, but then I saw similar things to you..
    So, I'm slowly playing and looking around...
    There was a bracket out of place, but I'm not even sure that matters. I toss in some debug logs and see some weird results. :)

    Here's the fixed line lol
    Code (csharp):
    1.  (buttons[currentIndex] == "left" && Input.GetAxisRaw("Horizontal") == -1)
     
    TreasureChestMimic likes this.
  3. TreasureChestMimic

    TreasureChestMimic

    Joined:
    Jan 26, 2018
    Posts:
    8

    Sure enough that fixed it! Thank you so much for your help!
     
  4. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    No problem. :) Neat little script.