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

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

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 to get smooth analog joystick rotation without "snapping"? 2 Answers

Get key pressed. 3 Answers

Input.acceleration with Screen.width 1 Answer

Getting My Character to Move 1 Answer

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