Added interact input
This commit is contained in:
@@ -46,6 +46,15 @@ namespace Input
|
||||
""processors"": """",
|
||||
""interactions"": """",
|
||||
""initialStateCheck"": false
|
||||
},
|
||||
{
|
||||
""name"": ""Interact"",
|
||||
""type"": ""Button"",
|
||||
""id"": ""a0a57f7b-062d-458c-a85a-d6030c412835"",
|
||||
""expectedControlType"": ""Button"",
|
||||
""processors"": """",
|
||||
""interactions"": """",
|
||||
""initialStateCheck"": false
|
||||
}
|
||||
],
|
||||
""bindings"": [
|
||||
@@ -136,6 +145,28 @@ namespace Input
|
||||
""action"": ""Jump"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": """",
|
||||
""id"": ""4eb9a209-b978-4daf-927a-2f013348d294"",
|
||||
""path"": ""<Keyboard>/z"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": ""KeyBoard"",
|
||||
""action"": ""Interact"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": """",
|
||||
""id"": ""c2dc0361-1191-4641-97e6-d105f64ee7ff"",
|
||||
""path"": ""<Gamepad>/buttonEast"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": ""Controller"",
|
||||
""action"": ""Interact"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": false
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -169,6 +200,7 @@ namespace Input
|
||||
m_PlayerControl = asset.FindActionMap("PlayerControl", throwIfNotFound: true);
|
||||
m_PlayerControl_Move = m_PlayerControl.FindAction("Move", throwIfNotFound: true);
|
||||
m_PlayerControl_Jump = m_PlayerControl.FindAction("Jump", throwIfNotFound: true);
|
||||
m_PlayerControl_Interact = m_PlayerControl.FindAction("Interact", throwIfNotFound: true);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
@@ -230,12 +262,14 @@ namespace Input
|
||||
private IPlayerControlActions m_PlayerControlActionsCallbackInterface;
|
||||
private readonly InputAction m_PlayerControl_Move;
|
||||
private readonly InputAction m_PlayerControl_Jump;
|
||||
private readonly InputAction m_PlayerControl_Interact;
|
||||
public struct PlayerControlActions
|
||||
{
|
||||
private @PlayerInput m_Wrapper;
|
||||
public PlayerControlActions(@PlayerInput wrapper) { m_Wrapper = wrapper; }
|
||||
public InputAction @Move => m_Wrapper.m_PlayerControl_Move;
|
||||
public InputAction @Jump => m_Wrapper.m_PlayerControl_Jump;
|
||||
public InputAction @Interact => m_Wrapper.m_PlayerControl_Interact;
|
||||
public InputActionMap Get() { return m_Wrapper.m_PlayerControl; }
|
||||
public void Enable() { Get().Enable(); }
|
||||
public void Disable() { Get().Disable(); }
|
||||
@@ -251,6 +285,9 @@ namespace Input
|
||||
@Jump.started -= m_Wrapper.m_PlayerControlActionsCallbackInterface.OnJump;
|
||||
@Jump.performed -= m_Wrapper.m_PlayerControlActionsCallbackInterface.OnJump;
|
||||
@Jump.canceled -= m_Wrapper.m_PlayerControlActionsCallbackInterface.OnJump;
|
||||
@Interact.started -= m_Wrapper.m_PlayerControlActionsCallbackInterface.OnInteract;
|
||||
@Interact.performed -= m_Wrapper.m_PlayerControlActionsCallbackInterface.OnInteract;
|
||||
@Interact.canceled -= m_Wrapper.m_PlayerControlActionsCallbackInterface.OnInteract;
|
||||
}
|
||||
m_Wrapper.m_PlayerControlActionsCallbackInterface = instance;
|
||||
if (instance != null)
|
||||
@@ -261,6 +298,9 @@ namespace Input
|
||||
@Jump.started += instance.OnJump;
|
||||
@Jump.performed += instance.OnJump;
|
||||
@Jump.canceled += instance.OnJump;
|
||||
@Interact.started += instance.OnInteract;
|
||||
@Interact.performed += instance.OnInteract;
|
||||
@Interact.canceled += instance.OnInteract;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -287,6 +327,7 @@ namespace Input
|
||||
{
|
||||
void OnMove(InputAction.CallbackContext context);
|
||||
void OnJump(InputAction.CallbackContext context);
|
||||
void OnInteract(InputAction.CallbackContext context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -22,6 +22,15 @@
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": false
|
||||
},
|
||||
{
|
||||
"name": "Interact",
|
||||
"type": "Button",
|
||||
"id": "a0a57f7b-062d-458c-a85a-d6030c412835",
|
||||
"expectedControlType": "Button",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": false
|
||||
}
|
||||
],
|
||||
"bindings": [
|
||||
@@ -112,6 +121,28 @@
|
||||
"action": "Jump",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "4eb9a209-b978-4daf-927a-2f013348d294",
|
||||
"path": "<Keyboard>/z",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "KeyBoard",
|
||||
"action": "Interact",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "c2dc0361-1191-4641-97e6-d105f64ee7ff",
|
||||
"path": "<Gamepad>/buttonEast",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "Controller",
|
||||
"action": "Interact",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@@ -2,10 +2,11 @@ using System;
|
||||
using Movement;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using PlayerInput = Input.PlayerInput;
|
||||
|
||||
namespace Player
|
||||
{
|
||||
public class PlayerController : MonoBehaviour, IMovement, Input.PlayerInput.IPlayerControlActions
|
||||
public class PlayerController : MonoBehaviour, IMovement, PlayerInput.IPlayerControlActions
|
||||
{
|
||||
private const float DefaultJumpForce = 9.81f;
|
||||
private const float DefaultMass = 80.0f;
|
||||
@@ -23,18 +24,19 @@ namespace Player
|
||||
private bool _isOnAir;
|
||||
|
||||
private float _xAxisValue;
|
||||
private PlayerInput.IPlayerControlActions _playerControlActionsImplementation;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
this._playerRigidbody2D = gameObject.GetComponent<Rigidbody2D>();
|
||||
this._playerGroundTrigger = GameObject.Find("PlayerGroundTrigger").GetComponent<CollisionChecker>();
|
||||
this._playerSpriteRenderer = gameObject.GetComponent<SpriteRenderer>();
|
||||
_playerRigidbody2D = gameObject.GetComponent<Rigidbody2D>();
|
||||
_playerGroundTrigger = GameObject.Find("PlayerGroundTrigger").GetComponent<CollisionChecker>();
|
||||
_playerSpriteRenderer = gameObject.GetComponent<SpriteRenderer>();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
this._playerRigidbody2D.gravityScale = GravityScale;
|
||||
this._playerRigidbody2D.mass = DefaultMass;
|
||||
_playerRigidbody2D.gravityScale = GravityScale;
|
||||
_playerRigidbody2D.mass = DefaultMass;
|
||||
BaseSpeed = DefaultSpeed;
|
||||
}
|
||||
|
||||
@@ -42,7 +44,7 @@ namespace Player
|
||||
{
|
||||
if (_controls == null)
|
||||
{
|
||||
_controls = new Input.PlayerInput();
|
||||
_controls = new PlayerInput();
|
||||
_controls.PlayerControl.SetCallbacks(this);
|
||||
}
|
||||
|
||||
@@ -72,11 +74,13 @@ namespace Player
|
||||
public void Pause()
|
||||
{
|
||||
IsPaused = true;
|
||||
_playerRigidbody2D.simulated = IsPaused;
|
||||
}
|
||||
|
||||
public void Resume()
|
||||
{
|
||||
IsPaused = false;
|
||||
_playerRigidbody2D.simulated = IsPaused;
|
||||
}
|
||||
|
||||
// MOVE METHODS
|
||||
@@ -134,5 +138,10 @@ namespace Player
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnInteract(InputAction.CallbackContext context)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user