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 Sensisensic · Jan 21, 2013 at 05:35 PM · input2 player

Problem with 2 player mirroring input

I'm having a bit of an issue with 2 player input. It's my first time trying it, and I believe I got all the parts right, but something is still wrong.

I have 2 players on screen, all the movement controls are separate and work fine, but whenever I try to fire a player's lazer it fires it on both players.

I have checked and double checked everything, there are no naming mistakes going on, everything is separate. This is the script which handles the instantiate of the lazer, for player 1:

 var p1Lazer : GameObject;
 var p1LazerGun : GameObject;

 function Update (){
     if (Input.GetButtonDown("P1Lazer")){
         var p1NewLazer : GameObject = Instantiate(p1Lazer, transform.position, transform.rotation);
         p1NewLazer.transform.parent = p1LazerGun.transform;
     }
 }

And for player 2:

 var p2Lazer : GameObject;
 var p2LazerGun : GameObject;

 function Update (){
     if (Input.GetButtonDown("P2Lazer")){
         var p2NewLazer : GameObject = Instantiate(p2Lazer, transform.position, transform.rotation);
         p2NewLazer.transform.parent = p2LazerGun.transform;
     }
 }

And as for the input settings:

alt text

For some reason it's recognizing the joystick button input as the same for both controllers, while I have it listed on a separate controller in the input settings and I have given it different names. And I follow the same naming conventions for movement and that all works fine, but this does not. There is something wrong with that lazer instantiate script I believe (if I turn this script off on 1 player it does not fire the lazer on that player; it does on the other player). I have restarted Unity and my PC (so it's not my PC still configuring the joysticks), also plugged the joysticks in and out more than once. Scripts are added to the gameobjects properly. Do you maybe have any idea what's going on? It's a mystery to me.

If it helps I could upload the project folder.

Comment
Add comment · Show 2
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 Sensisensic · Jan 21, 2013 at 08:20 PM 0
Share

Alright, so it's not the instantiate script, since I just did a check: if(Input.GetButtonDown("P1Lazer")){print("P1Lazer");} and also for P2Lazer, and I get a response from both. So it's something to do with recognizing input I guess.

avatar image Sensisensic · Jan 21, 2013 at 08:34 PM 0
Share

So to check it up further I changed the joystick input on P2Lazer to spacebar. Then it works fine, it accurately differentiates between player 1's lazer en player 2's lazer and they don't fire both. But what's wrong with the joystick input then the way as it is entered in the image above?

1 Reply

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

Answer by Loius · Jan 21, 2013 at 08:42 PM

"Joystick Button X" means "Button #X on any joystick."

"Joystick Y Button X" means "Button #X on Joystick #Y"

The "Joystick Y" you've selected down below only applies to the axis inputs.

:science:

Comment
Add comment · Show 2 · 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 Sensisensic · Jan 21, 2013 at 08:44 PM 0
Share

I figured the joy num setting on the bottom of the input listing would change that, but apparently you do have to write down the input setting as "joystick 2 button 4" etc. Damnit :p facepalm

avatar image Loius · Jan 22, 2013 at 01:56 AM 0
Share

Oh yes indeed. I imagine there have been so many facepalms on this topic that ... well... something drastic. Lots.

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

10 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

Related Questions

Separate GUI for each player? 1 Answer

Help In Making a SphereCast for 3D Tire! Working RayCast Script included! 0 Answers

Unity loses focus when Oculus display activated 1 Answer

How to move the player object in the same direction as the input axis, considering the cameras direction? 0 Answers

How to use Button as Cross Platform Input 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