I’m using PlayerInput component together with InputActions asset. Unity Version 6000.0.2f1
Here is my code:
private PlayerInput _playerInput;
private InputAction _moveAccelerationAction;
private void Start()
{
_playerInput = GetComponent<PlayerInput>();
_moveAccelerationAction = _playerInput.actions["MoveAcceleration"];
if (_moveAccelerationAction == null)
Debug.LogError("MoveAcceleration action not found");
_moveAccelerationAction.Enable();
}
private void Update()
{
if (!Accelerometer.current.enabled)
{
foreach (var device in InputSystem.devices)
{
if (device is Accelerometer)
{
InputSystem.EnableDevice(device);
}
}
var ctx = _moveAccelerationAction.ReadValue<InputAction.CallbackContext>();
// var ctx = _moveAccelerationAction.ReadValue<Vector3>();
Debug.Log(ctx);
}
}
Output:
{ action= phase=Disabled time=0 control= value= interaction= }
- if use
ReadValue<Vector3>()→0,0,0 - I checked
ProjectSettings.assetaccelerometerFrequency:60. - I tried
_moveAccelerationAction.performed +=, it won’t perform. - I tried
Accelerometer.current.acceleration.ReadValue();and I can get the values, but that will make myInputActionsasset setup quite meaningless as I made some control schemes.
Inspector:
InputActions asset:
Thanks for helping!

