feat(PlayerMovement): Enhance input action handling for backward compatibility
This commit is contained in:
@@ -50,8 +50,9 @@ public class PlayerMovement : MonoBehaviour
|
||||
m_moveAction = map.FindAction("Move");
|
||||
m_lookAction = map.FindAction("Look");
|
||||
m_jumpAction = map.FindAction("Jump");
|
||||
m_throwAction = map.FindAction("Throw");
|
||||
m_pickupAction = map.FindAction("Pickup");
|
||||
// Support both old and new action names without breaking the scene setup.
|
||||
m_throwAction = map.FindAction("Throw") ?? map.FindAction("Attack");
|
||||
m_pickupAction = map.FindAction("Pickup") ?? map.FindAction("Interact");
|
||||
|
||||
m_rigidbody = GetComponent<Rigidbody>();
|
||||
animator = GetComponent<Animator>();
|
||||
@@ -76,20 +77,20 @@ public class PlayerMovement : MonoBehaviour
|
||||
|
||||
private void Update()
|
||||
{
|
||||
m_moveAmt = m_moveAction.ReadValue<Vector2>();
|
||||
m_lookAmt = m_lookAction.ReadValue<Vector2>();
|
||||
m_moveAmt = m_moveAction != null ? m_moveAction.ReadValue<Vector2>() : Vector2.zero;
|
||||
m_lookAmt = m_lookAction != null ? m_lookAction.ReadValue<Vector2>() : Vector2.zero;
|
||||
|
||||
if (m_jumpAction.WasPressedThisFrame())
|
||||
if (m_jumpAction != null && m_jumpAction.WasPressedThisFrame())
|
||||
{
|
||||
Jump();
|
||||
}
|
||||
|
||||
if (m_throwAction.WasPressedThisFrame())
|
||||
if (m_throwAction != null && m_throwAction.WasPressedThisFrame())
|
||||
{
|
||||
ThrowHead();
|
||||
}
|
||||
|
||||
if (m_pickupAction.WasPressedThisFrame())
|
||||
if (m_pickupAction != null && (m_pickupAction.WasPressedThisFrame() || m_pickupAction.WasPerformedThisFrame()))
|
||||
{
|
||||
TryPickupHead();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user