Reputation: 111
I'm creating a shooting system like angry birds with press/release in the new input system. It works with a mouse but I'm having trouble with mobile.
In input actions I assigned
Shoot:
[Left Mouse Button]
&
[Primary Touch/Touch Contact] [Touchscreen]
for the same action, both with press and release behavior.
The mouse position is MousePosition:
Position[Mouse]
& Primary Touch/Position [Touchscreen]
private void OnEnable()
{
controls.Gameplay.Enable();
controls.Gameplay.Shoot.started += ctx => PlayerAimingStart(ctx);
controls.Gameplay.Shoot.canceled += ctx => PlayerAimingCanceled(ctx);
}
private void PlayerAimingStart(InputAction.CallbackContext context)
{
Debug.Log("start");
shootingPositionStart = controls.Gameplay.MousePosition.ReadValue<Vector2>(); shootingPositionStart.z = 0f;
}
private void PlayerAimingCanceled(InputAction.CallbackContext context)
{
Debug.Log("canceled");
shootingPositionEnd = controls.Gameplay.MousePosition.ReadValue<Vector2>(); shootingPositionEnd.z = 0f;
Shoot();
I have movement with the keyboard WASD keys and the onscreen joystick with Left Stick [Gamepad]
; the joystick works fine with Unity Remote on an android phone. The Build setting is set to Android.
I've tried to print with debug.log without result.
Also in the update function there was no input for MousePosition
(for mobile using a mouse, it works).
I tried to make another action TouchPosition
with Primary Touchscreen [position]
but also no results. Like my phone is dead but it somehow works with joystick.
Upvotes: 2
Views: 9257
Reputation: 308
Yeah Unity Remote doesn't work with Unity's New Input System, but you can use Legacy Input System by enabling both in Edit -> Project Settings -> Player -> Active Input Handling to "Both".
For development, you can use "both" input systems and for production, you can switch to "New Input System" because only Unity's Remote doesn't support New Input System, but Your Mobile Build will work with New Input System
In Simple words:
Use "Both" Input for Remote Play (For Development)
Use "New Input System" for Mobile Build App (For Production)
I'm just using this technique. It just works fine!
Upvotes: 4