Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
1
Question by FreeTimeDev · Oct 12, 2010 at 11:59 AM · inputcontrollerkeyboardcontrols

Removing Joystick Controls

I need to remove the default ability of receiving input from All Joysticks. As seen here: http://unity3d.com/support/documentation/Components/class-InputManager.html. I do not see an option similar to "Do not get motion from joysticks".

(Local Multiplayer) I'd like to have a control scheme for the keyboard, and another player use an xbox controller. However, I cannot remove player 1's ability to accept input from the controller.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Bravini · Oct 12, 2010 at 09:12 PM

a simple workaround would be to set the input scripts of player two as different inputs in the input manager, and don't configure joystick buttons or axis for it. An easy way to do this woud be to check the player to see if it's the player 2 and run the Walk2 instead of Walk.

Comment
Add comment · Show 5 · Share
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 FreeTimeDev · Oct 14, 2010 at 12:26 PM 0
Share

So "Player 1" would have to have control of the keyboard and at least the joysticks of the first controller? I must be missing something. How would one do local multiplayer with two people and multiple "controllers" ($$anonymous$$B or Gamepad)?

At present, Player 1 is effected by Horiz and Verti Joystick movement of the first joystick. There wouldn't be a way to let player 2 plug in an xbox controller and play, because this would turn out to be joystick 1?

avatar image Bravini · Oct 15, 2010 at 07:46 PM 0
Share

you`d have "horizontal" receiving input from joystick 1 on Joy Num setting on Input $$anonymous$$anager and "horizontal" (same name) receiving from Joy Num 2 or with "$$anonymous$$ey or $$anonymous$$ouse Button" on Type Setting. $$anonymous$$eyboard player will receive type "mouse or key button" so it ignores joystick inputs and joystick num 1 for example, while joystick player will have joystick num 2 and type "joystick axis" will ignore keyboard inputs.

avatar image Bravini · Oct 15, 2010 at 07:49 PM 0
Share

same input names and scripts, with same name inputs on input manager but different type and joy num settings

avatar image FreeTimeDev · Oct 17, 2010 at 06:29 AM 0
Share

I think, perhaps, my problem is laziness. I just applied their character controller and it accepts both.

avatar image FreeTimeDev · Oct 17, 2010 at 06:51 AM 0
Share

After fiddling with this some more, I found the error was actually my mistake. I had (either by choice or default) the axes $$anonymous$$anager set to a larger than needed number (17). This added multiple Horizontal and Verticals.

avatar image
0

Answer by idbrii · Sep 13, 2014 at 06:00 PM

The "Do not get motion from joysticks" option you're looking for is called "Joy Num".

To make your inputs work for multiple users, name your inputs after the player and always use numbered joysticks:

  • Axes: Create "P1_Horizontal" and select "Joystick 1" from the "Joy Num" dropdown.

  • Button: Create "P1_Jump" use "joystick 1 button 1".

  • Duplicate these for P2 and use "joystick 2"

In your player controller, add a public variable for the prefix ("P1_") and when calling GetAxes, prepend that prefix:

 public string playerPrefix = "P1_";

 ...
 {
     bool is_jump = Input.GetButtonDown(playerPrefix + "Jump");
     ...
 }

(If you're worried about the performance impact of string concatenation, define public variables for all of your inputs so you can pass them directly into GetButtonDown.)

When you add players to your scene, make sure you update their playerPrefix variable.

Following this pattern will allow you to keep your player controller code the same for two or more players. It should allow players to map different controls on each joystick or on the keyboard.

I got the joystick button names from here

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

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.

Follow this Question

Answers Answers and Comments

1 Person is following this question.

avatar image

Related Questions

On Screen Keyboard (PC and Console) best practices 3 Answers

How do I add input for two different local players? 1 Answer

How to change the default button inputs for the unity character controller,How to change the input keys for the unity character controller? 0 Answers

Assign and detect controls for each character to different gamepads and/or mouse and keyboard 0 Answers

Dynamically Assign Axes to a float value. 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