• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by nielspieleke · Feb 15, 2015 at 08:50 PM · inputenumgetkey

Gamepad input enum eType not working

I am making a SIMON game on PS Vita. I want to have touch but also button controls. I have the touch controls working as they should but the gamepad buttons don't work at all. I tried several things with 'GetKey' and 'GetButton' but it just isn't working. The part of "void Update" works. The last three parts are the working touch parts, the rest is the not working buttons part. The buttons are representing the four colors of the game. Some help would be much appreciated! The code I'm using:

 void Update(){
         if (Input.GetButtonDown("START")) {
             Application.LoadLevel (2);
         }
         else if (Input.GetButtonDown("L")) {
             Application.LoadLevel (0);
         }
         else if (Input.GetButtonDown("SELECT")) {
             Application.LoadLevel (1);
         }
     }
     
     SimonLightPlate.eType GetKey(string name){
         if (Input.GetKey(KeyCode.Joystick1Button1)){
             return SimonLightPlate.eType.BLUE;
         }
         return SimonLightPlate.eType.INVALID_TYPE;
     }
 
     void OnKeyDown() {
         if (Input.GetKey(0)) {
             this.SendMessageUpwards("OnLeftClickDown", GetKey(this.name), SendMessageOptions.DontRequireReceiver);
             //return SimonLightPlate.eType.BLUE;
             Debug.Log ("O Works");
         }
     }
 
     void OnKeyUp() {
         if (Input.GetKey(0)) {
             this.SendMessageUpwards("OnLeftClickUp", GetKey(this.name), SendMessageOptions.DontRequireReceiver);
             //return SimonLightPlate.eType.BLUE;
             Debug.Log ("O Works");
         }
     }
 
     //private SimonSays simonsays;
      SimonLightPlate.eType GetColorPlate(string clickPlaneStr){
         if (this.name == "BlueClick"){
             return SimonLightPlate.eType.BLUE;
         }
         else if (this.name == "GreenClick"){
             return SimonLightPlate.eType.GREEN;
         }
         else if (this.name == "RedClick"){
             return SimonLightPlate.eType.RED;
         }
         else if (this.name == "YellowClick"){
             return SimonLightPlate.eType.YELLOW;
         }
         else if (this.name == "PlayClick"){
             Application.LoadLevel (2);
         }
         else if (this.name == "InstructionsClick"){
             Application.LoadLevel (1);
         }
         else if (this.name == "BackClick"){
             Application.LoadLevel (0);
         }
         else if (Input.GetKey(KeyCode.Joystick1Button1)) {
             return SimonLightPlate.eType.BLUE;
         }
         //else if (Input.GetButton("V")) {
         //    return SimonLightPlate.eType.GREEN;
         //}
         //else if (Input.GetButton("T")) {
         //    return SimonLightPlate.eType.RED;
         //}
         //else if (Input.GetButton("X")) {
         //    return SimonLightPlate.eType.YELLOW;
         //}
         return SimonLightPlate.eType.INVALID_TYPE;
     }
 
    void OnMouseOver() {
         if (Input.GetMouseButtonDown (0)) {
             this.SendMessageUpwards("OnLeftClickDown", GetColorPlate(this.name), SendMessageOptions.DontRequireReceiver);
         }
         //else if (Input.GetKeyDown(0)) {
         //    this.SendMessageUpwards("OnLeftClickDown", GetKey(0), SendMessageOptions.DontRequireReceiver);
         //}
     }
 
     void OnMouseUp() {
         if (Input.GetMouseButtonUp (0)) {
             this.SendMessageUpwards("OnLeftClickUp", GetColorPlate(this.name), SendMessageOptions.DontRequireReceiver);
         }
         //else if (Input.GetKeyUp(0)) {
         //    this.SendMessageUpwards("OnLeftClickUp", GetKey(0), SendMessageOptions.DontRequireReceiver);
         //}
     }
 }
 
Comment
Add comment · Show 5
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image meat5000 ♦ · Feb 15, 2015 at 04:55 PM 0
Share

Read this?

avatar image nielspieleke · Feb 15, 2015 at 05:26 PM 0
Share

Yes, many, many times.

avatar image meat5000 ♦ · Feb 15, 2015 at 07:12 PM 0
Share

What is Input.Get$$anonymous$$ey(0)?

avatar image nielspieleke · Feb 18, 2015 at 01:54 PM 0
Share

I tried to modify On$$anonymous$$ouseOver and On$$anonymous$$ouseUp(the last two parts) and so I replaced $$anonymous$$ouseButtonDown in: if (Input.Get$$anonymous$$ouseButtonDown(0)) {

with $$anonymous$$ey, because I want Gamepad input and want to use Input.Get$$anonymous$$ey to achieve that. I also tried Input.GetButton(0)

avatar image nielspieleke · Feb 18, 2015 at 01:57 PM 0
Share

I copied the last two parts( On$$anonymous$$ouseOver and On$$anonymous$$ouseUp) and replaced Input.Get$$anonymous$$ouseButtonDown with Input.Get$$anonymous$$ey, because I want gamepad controls besides the touch/mouse controls and would like to achieve that with Get$$anonymous$$ey. I also tried Input.GetButton.

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Input.GetKey() with multiple enum values (C#) 4 Answers

How to use number keys as a throttle? 0 Answers

Unity C# Two keys pressing one after another not doing a function vice versa 0 Answers

Input.GetKey not working 1 Answer

Catch Ctrl+Z input in Editor 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges