As the title says, I’m only able to get 8 directions from the joysticks.
[1,0]
[0,1]
[-1,0]
[0,-1]
[0.7, 0.7]
[0.7, -0.7]
[-0.7, 0.7]
[-0.7, -0.7]
and of course [0, 0]
Is anyone else getting this issue or am I just being an idiot?
This is the generated code:
""bindings"": [
{
""name"": ""Left Stick"",
""id"": ""fa27b3f9-4c13-4f0a-8b27-7486dd640241"",
""path"": ""2DVector"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Movement"",
""isComposite"": true,
""isPartOfComposite"": false,
""modifiers"": """"
},
{
""name"": ""up"",
""id"": ""f410eab2-de72-4ecc-932e-9e223baae5f9"",
""path"": ""<Gamepad>/leftStick/up"",
""interactions"": """",
""processors"": """",
""groups"": ""Controller"",
""action"": ""Movement"",
""isComposite"": false,
""isPartOfComposite"": true,
""modifiers"": """"
},
{
""name"": ""down"",
""id"": ""b0da6f0d-ecd0-4a6f-af3c-47febd5acf84"",
""path"": ""<Gamepad>/leftStick/down"",
""interactions"": """",
""processors"": """",
""groups"": ""Controller"",
""action"": ""Movement"",
""isComposite"": false,
""isPartOfComposite"": true,
""modifiers"": """"
},
{
""name"": ""left"",
""id"": ""e139f5c7-d7a7-4ef1-8061-b0e5c8224078"",
""path"": ""<Gamepad>/leftStick/left"",
""interactions"": """",
""processors"": """",
""groups"": ""Controller"",
""action"": ""Movement"",
""isComposite"": false,
""isPartOfComposite"": true,
""modifiers"": """"
},
{
""name"": ""right"",
""id"": ""40555fc7-b1fc-4557-8201-2a0d3f081969"",
""path"": ""<Gamepad>/leftStick/right"",
""interactions"": """",
""processors"": """",
""groups"": ""Controller"",
""action"": ""Movement"",
""isComposite"": false,
""isPartOfComposite"": true,
""modifiers"": """"
},
This is my code:
public void UpdatePosition(InputAction.CallbackContext context)
{
//Convert vector2 direcion to vector3 direction
Debug.Log(context.ReadValue<Vector2>());
Vector3 _moveDirection = new Vector3(context.ReadValue<Vector2>().x, 0, context.ReadValue<Vector2>().y);
//transform direction to camera
_moveDirection = Camera.main.transform.TransformDirection(_moveDirection);
_moveDirection.y = 0;
//_moveDirection.Normalize();
//apply speed and rotation
_currentSpeed = Mathf.Lerp(_currentSpeed, _moveSpeed(), 3f * Time.deltaTime);
_moveDirection *= _currentSpeed;
transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(_moveDirection), 3f * Time.deltaTime);
_player.Move(_moveDirection * Time.deltaTime);
}
public void OnMovement(InputAction.CallbackContext context)
{
_movementController.UpdatePosition(context);
if (context.canceled)
{
_movementController.StopMoving(context);
}
}