Is this by design (i.e. due to licensing issues, Joy-Con support won’t be implemented) or is it something that’s being worked on? I’d love to see how I can use the Joy-Cons in my projects, and it sounds like people have been able to get them to work with other methods (such as at GitHub - Looking-Glass/JoyconLib: Joy-Con library for Unity.), but it’d be quite nice to have this compatible with the standard input system.
@Moerge you are wrong! you use it in the new Input System package. right-click the package window > view in package manager > and search “Input System” and hit install.
Here is a little code I made for my game (No Errors):
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class Player : MonoBehaviour {
[I]//More on Code Monkey's channel[/I]
public float speed = 12f;
public float gravity = -9.81f;
public float jumpHeight = 3f;
Vector3 velocity;
private PlayerInput playerInput;
[I]//Needs Rigidbody component[/I]
public Rigidbody rb;
//Your Input asset (Convert to script)
private PlayerInputActions playerInputActions;
private void Awake()
{
playerInput = GetComponent<PlayerInput>();
playerInputActions = new PlayerInputActions();
playerInputActions.Gameplay.Enable();
playerInputActions.Gameplay.Jump.performed += Jump;
playerInputActions.Gameplay.Movement.performed += Movement_performed;
}
private void Movement_performed(InputAction.CallbackContext context)
{
Debug.Log(context);
Vector2 inputVector = context.ReadValue<Vector2>();
float speed = 5f;
rb.AddForce(new Vector3(inputVector.x, 0, inputVector.y) * speed, ForceMode.Force);
//throw new System.NotImplementedExeption();
}
private void Update()
{
Vector2 inputVector = playerInputActions.Gameplay.Movement.ReadValue<Vector2>();
float speed = 5f;
rb.AddForce(new Vector3(inputVector.x, 0, inputVector.y) * speed, ForceMode.Force);
}
//Jump
public void Jump(InputAction.CallbackContext context)
{
if(context.performed)
{
velocity.y = Mathf.Sqrt(jumpHeight * -2f * gravity);
Debug.Log("Jump!");
}
}
//Crouch
public void CrouchDown(InputAction.CallbackContext context)
{
Vector3 scale = transform.localScale;
scale.y = 0.4796073F;
transform.localScale = scale;
}
//Stand Up
public void Stand(InputAction.CallbackContext context)
{
Vector3 scale = transform.localScale;
scale.y = 1F;
transform.localScale = scale;
}
public void Movement(InputAction.CallbackContext context)
{
Debug.Log("Forward");
rb.AddForce(0, 0, 50);
}
}
[I]//More on Code Monkey's channel[/I]
I’ll have to give it another try today, just in case it somehow slipped through - but as I recall, I think the Input System may by default support Joy-Cons as super-basic HID controllers. The joysticks provided very limited information, and maybe the trigger buttons didn’t work? On top of that there was no support for things like rumble. I made a plug-in last year to support these things, but it was incomplete and had various issues: https://github.com/Meorge/JoyConUnityInputSystem
I’m hoping that “rich support” will be added that can take advantage of the Joy-Cons’ capabilities, not just the poor basic HID support they provide by default.