Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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 /
  • Help Room /
This question was closed Feb 01, 2016 at 02:29 AM by TabuuForteAkugun for the following reason:

Got it. It was a bug in my code. I used the wrong comparison operator ( OR when I should have used an AND) in the constructor's If statement. So an ID never got assigned, never activating the controller.

avatar image
0
Question by TabuuForteAkugun · Feb 01, 2016 at 02:26 AM · c#xboxcontrollerxbox360

XInputDotNetPure - Controller won't activate

So yeah, I got XInputDotNetPure and copied XInputInterface.dll to my project's root folder as per the instructions.

I set up my code as follows, to handle controller input (WIP) My game supports up to four gamepads at once, hence the class. The class is instantiated 4 times in an array of four objects of type XInput_Controller, each with their PlayerIndex. Here is the XInput_Controller class.

 /*
  * XBOX 360 / USB XINPUT CONTROLLER SETUP.
  * Enable support for controllers in Unity and dynamically manage them.
  * Note: Make sure you have the appropriate driver(s) to use the controllers!
  */ 
 
 using UnityEngine;
 using System.Collections;
 using System.Collections.Generic;
 using XInputDotNetPure;
 
 public class XInput_Controller
 {
     // Indices.
     private PlayerIndex xi_PadID;        // Pad ID / Index.
 
     // Game Pad's states.
     private GamePadState xi_Current;     // Current Pad state.
     private GamePadState xi_Previous;    // Previous Pad state.
 
     public XInput_Controller(int id)
     {
         if (id > 1 || id < 4)
         {
             xi_PadID = (PlayerIndex)id;     // Same value as a PlayerIndex.
         }
         else
         {
             Debug.Log(id.ToString() + " isn't a valid Game Pad index!");
         }
         xi_Current = GamePad.GetState(xi_PadID);
     }
 
     // Accessing private vars for If statements.
 
     public bool GetConnection()
     {
         return xi_Current.IsConnected;
     }
 
     public int GetPadID()
     {
         return (int)xi_PadID;
     }
 
     public GamePadState GetCurrentState()
     {
         return xi_Current;
     }
 
     public GamePadState GetPreviousState()
     {
         return xi_Previous;
     }
 
     public void UpdatePad()
     {
         xi_Previous = xi_Current;
         xi_Current = GamePad.GetState(xi_PadID);
     }
 }

I ran a diagnostic test in the code for the scene I wanted to test my controller in. (I have one plugged in, the others are just inactive). It was through Debug.Log();, and passed the connection status of my pad through it. Keeps returning false although the darn thing is connected in any other program.

The problem lies in the fact that the controller never gets turned on and activated in-game (I test in Test Play mode since building takes ages) Unity recognizes that it's plugged in with the Joystick Connected (Controller) message in the console. Windows itself knows it's there and also registers input in the driver settings in Device Manager. I installed the XBox 360 Gaming accessories driver on it as well. (Model: F310 Logitech wired game pad). It worked flawlessly once, but completely stopped responding to input now. I use Unity 5.3.2 p1, I think, on Windows 8.1 I mash buttons like crazy and nothing happens.

Simply put, my game simply won't recognize the pad.

I don't get it. All I want to do is start working on my game's playability, and since it's a Super Smash Bros. fangame, it needs controllers and axis input. for precise movement and 4 player multiplayer.

I even run the UpdatePad() method in the scene's update. The input refuses to work in any capacity.

Anyone able to help?

Comment
Add comment
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

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

73 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Xbox 360 left and right triggers mixed up with multiple controllers 0 Answers

XB1 controller vibration using XInput not working on XB1 console 0 Answers

FindGameObjectWithTag (Multiple Objects) 1 Answer

Custom OnSceneGUI-editor not working for ScriptableObjects? 2 Answers

Will this work? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges