|
@ -16,7 +16,10 @@ public class HandController : MonoBehaviour |
|
|
[SerializeField, BoxGroup("References")] |
|
|
[SerializeField, BoxGroup("References")] |
|
|
private Transform m_handTransform; |
|
|
private Transform m_handTransform; |
|
|
|
|
|
|
|
|
[SerializeField] |
|
|
|
|
|
|
|
|
[SerializeField, BoxGroup("References")] |
|
|
|
|
|
private OarController m_oar; |
|
|
|
|
|
|
|
|
|
|
|
[SerializeField,BoxGroup("settings")] |
|
|
private Transform m_otherHand; |
|
|
private Transform m_otherHand; |
|
|
|
|
|
|
|
|
[SerializeField, BoxGroup("Settings")] |
|
|
[SerializeField, BoxGroup("Settings")] |
|
@ -27,9 +30,12 @@ public class HandController : MonoBehaviour |
|
|
[SerializeField, BoxGroup("Settings")] |
|
|
[SerializeField, BoxGroup("Settings")] |
|
|
private float m_armRange = 1; |
|
|
private float m_armRange = 1; |
|
|
|
|
|
|
|
|
[SerializeField, BoxGroup("Settings"),Range(0.0f,1.0f)] |
|
|
|
|
|
|
|
|
[SerializeField, BoxGroup("Settings"), Range(0.0f, 1.0f)] |
|
|
private float m_armSpeed = 0.5f; |
|
|
private float m_armSpeed = 0.5f; |
|
|
|
|
|
|
|
|
|
|
|
[SerializeField, BoxGroup("Settings")] |
|
|
|
|
|
private Vector2 m_startInput = new Vector2(0, 1); |
|
|
|
|
|
|
|
|
[SerializeField, BoxGroup("Input")] |
|
|
[SerializeField, BoxGroup("Input")] |
|
|
private InputActionProperty m_inputAxis; |
|
|
private InputActionProperty m_inputAxis; |
|
|
|
|
|
|
|
@ -47,6 +53,7 @@ public class HandController : MonoBehaviour |
|
|
private Vector3 m_startPosition; |
|
|
private Vector3 m_startPosition; |
|
|
private Vector3 m_lastPosition; |
|
|
private Vector3 m_lastPosition; |
|
|
|
|
|
|
|
|
|
|
|
private bool m_doUndo; |
|
|
#endregion Private Fields
|
|
|
#endregion Private Fields
|
|
|
|
|
|
|
|
|
#region Getters
|
|
|
#region Getters
|
|
@ -59,7 +66,8 @@ public class HandController : MonoBehaviour |
|
|
|
|
|
|
|
|
private void Start() |
|
|
private void Start() |
|
|
{ |
|
|
{ |
|
|
m_startPosition = transform.localPosition; |
|
|
|
|
|
|
|
|
m_startPosition = transform.localPosition; |
|
|
|
|
|
UpdateHand(m_startInput); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
@ -95,20 +103,21 @@ public class HandController : MonoBehaviour |
|
|
#endregion MonoBehaviour Functions
|
|
|
#endregion MonoBehaviour Functions
|
|
|
|
|
|
|
|
|
#region Class Functionality
|
|
|
#region Class Functionality
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Called every fixed update to move the arms
|
|
|
/// Called every fixed update to move the arms
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="input"></param>
|
|
|
/// <param name="input"></param>
|
|
|
private void UpdateHand(Vector2 input) |
|
|
|
|
|
|
|
|
private void UpdateHand(Vector2 input, bool registerUndo = true) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
m_lastPosition = transform.localPosition; |
|
|
m_lastPosition = transform.localPosition; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Quaternion rotation = Quaternion.LookRotation(m_axisForward.normalized, m_axisNormal.normalized); |
|
|
Quaternion rotation = Quaternion.LookRotation(m_axisForward.normalized, m_axisNormal.normalized); |
|
|
Vector3 axisInput = transform.rotation * rotation * new Vector3(input.x, 0, input.y); |
|
|
Vector3 axisInput = transform.rotation * rotation * new Vector3(input.x, 0, input.y); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Vector3 desiredPosition = m_startPosition + axisInput * m_armRange; |
|
|
Vector3 desiredPosition = m_startPosition + axisInput * m_armRange; |
|
|
transform.localPosition = Vector3.Lerp(transform.localPosition, desiredPosition, m_armSpeed); |
|
|
transform.localPosition = Vector3.Lerp(transform.localPosition, desiredPosition, m_armSpeed); |
|
|
|
|
|
|
|
@ -120,13 +129,15 @@ public class HandController : MonoBehaviour |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void UndoLastMovement() |
|
|
public void UndoLastMovement() |
|
|
{ |
|
|
{ |
|
|
transform.localPosition = m_lastPosition; |
|
|
|
|
|
|
|
|
Vector3 direction = m_lastPosition - transform.localPosition; |
|
|
|
|
|
|
|
|
|
|
|
transform.localPosition += direction; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -136,8 +147,8 @@ public class HandController : MonoBehaviour |
|
|
/// <param name="args"></param>
|
|
|
/// <param name="args"></param>
|
|
|
private void OnInputRecieved(InputAction.CallbackContext args) |
|
|
private void OnInputRecieved(InputAction.CallbackContext args) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
m_desiredInput = args.ReadValue<Vector2>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_desiredInput = args.ReadValue<Vector2>(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -150,7 +161,7 @@ public class HandController : MonoBehaviour |
|
|
private void Reset() |
|
|
private void Reset() |
|
|
{ |
|
|
{ |
|
|
m_handTransform = base.transform; |
|
|
m_handTransform = base.transform; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
#endregion Editor Functions
|
|
|
#endregion Editor Functions
|
|
|
|
|
|
|
|
|
} |
|
|
} |