- Home /
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
Your answer
Follow this Question
Related Questions
Help In Making a SphereCast for 3D Tire! Working RayCast Script included! 0 Answers
How to use if statements with New Input System? 1 Answer
[SOLVED] Input.GetAxis("Horizontal") returns wrong value? -1 Answers
How to make floating mobile keyboard in mobile game ? 0 Answers
Transition based off day length speed? ( day/night system) 1 Answer