• 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 GuillaumeGA · Jan 18, 2021 at 10:55 AM · input

New Input System : How to differentiate 2 players, but the 2 players have the same Player Input

i make Super_Smash Like games, but i have a lot of problems with the new Input System, Yeah the system is cool i can set the action i want with the button or axis i want.

But All the bugs PFIOUUUU.......

I try to make 2 player with the same prefab, and an identical playerInput, i success to instantiate them when i am in my combat scene but with the actual configuration, the 2 players do the same action at the same time, but i want them to do the action by their devices, how i can do that ?

     ![void Awake()
     {
         /* Contrôles */
         controls = new Controls();
      }
 
     private void OnEnable()
     {
         controls.GlobalActionMap.Enable();
 
         // this call the function but for all the players
         controls.GlobalActionMap.Simple_Attack.started += ctx => OnControl_SimpleAttack_Pressed();
         controls.GlobalActionMap.Jump.started += ctx => OnControl_Jump_Pressed();
         controls.GlobalActionMap.Move.performed += ctx => OnControl_Move_Performed(ctx);
         controls.GlobalActionMap.Aim.performed += ctx => OnControl_Aim_Performed(ctx);
 }
 
     private void OnDisable()
     {
         controls.GlobalActionMap.Disable();
     }
 
     // Axe x & y (joystick gauche)
     public void OnControl_Move_Performed(InputAction.CallbackContext _ctx)
     {
         moveInputControl = _ctx.ReadValue<Vector2>();
     }
 
     // Axe x & y (joystick droit)
     public void OnControl_Aim_Performed(InputAction.CallbackContext _ctx)
     {
         aimInputControl = _ctx.ReadValue<Vector2>();
     }
 
     // Call the event jump
     public void OnControl_Jump_Pressed()
     {
         Debug.LogWarning(this.name + " OnJump is called");
 
         if (isJumping == false && isGrounded == true)
         {
             //Debug.Log(this.name + " isJumping");
             isJumping = true;
         }
 
         if (isJumpingWallJump == false && (isHangingWallLeft == true || isHangingWallRight == true))
         {
             isJumpingWallJump = true;
 
             isJumpingWall_CallEvent = true;
             if (isHangingWallLeft == true)
             {
                 isJumpingWallLeft_CallEvent = true;
             }
             if (isHangingWallRight == true)
             {
                 isJumpingWallRight_CallEvent = true;
             }
         }
     }
 
     /// <summary>
     /// OnSimpleAttack_Pressed
     /// - appeler seulement quand la touche d'attaque est presser
     /// </summary>
     public void OnControl_SimpleAttack_Pressed()
     {
         // je joue le son de l'attaque, la position du son et a la position du coup
         Debug.LogWarning(this.name + " SoundManager playSound");
         SoundManager.PlaySound(SoundManager.SoundType.SimpleAttack, TransformPosAttack_Simple.position);
 
         IsDoing_SimpleAttack = true;
     }][1]


[1]: /storage/temp/174304-captureplayerinput.png

capture.png (49.5 kB)
captureplayerinput.png (69.6 kB)
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

· 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.

Follow this Question

Answers Answers and Comments

139 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 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

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

How set vive controller with input manager? 0 Answers

Problem setting up twin stick shooter for mobile device... 1 Answer

How to convert a camera controller code to the "new" input system? 0 Answers

Speed pickup 1 Answer


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