|
@ -9,7 +9,7 @@ public class PlayerInputController : InputBehaviour |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[SerializeField] |
|
|
[SerializeField] |
|
|
private float m_playerSpeed = 1; |
|
|
|
|
|
|
|
|
public float m_playerSpeed = 1; |
|
|
|
|
|
|
|
|
[SerializeField] |
|
|
[SerializeField] |
|
|
private float m_rotationSpeed = 1; |
|
|
private float m_rotationSpeed = 1; |
|
@ -29,10 +29,13 @@ public class PlayerInputController : InputBehaviour |
|
|
private Vector3 m_desiredDirection; |
|
|
private Vector3 m_desiredDirection; |
|
|
private bool m_recievedInput => m_desiredDirection.magnitude != 0; |
|
|
private bool m_recievedInput => m_desiredDirection.magnitude != 0; |
|
|
|
|
|
|
|
|
|
|
|
public Vector3 m_CameraForwards; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void Awake() |
|
|
private void Awake() |
|
|
{ |
|
|
{ |
|
|
m_controller = GetComponent<CharacterController>(); |
|
|
m_controller = GetComponent<CharacterController>(); |
|
|
|
|
|
//m_CameraForwards = Vector3.ProjectOnPlane(Camera.main.transform.forward,Vector3.up).normalized;
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -53,16 +56,11 @@ public class PlayerInputController : InputBehaviour |
|
|
|
|
|
|
|
|
private void ApplyRotation() |
|
|
private void ApplyRotation() |
|
|
{ |
|
|
{ |
|
|
transform.forward = Vector3.Slerp(transform.forward, m_desiredDirection.normalized, m_rotationSpeed * Time.deltaTime); |
|
|
|
|
|
|
|
|
transform.forward = Vector3.Slerp(transform.forward, m_desiredDirection, m_rotationSpeed * Time.deltaTime); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void ApplyMovement() |
|
|
private void ApplyMovement() |
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
float forwardRatio = (Vector3.Dot(transform.forward, m_desiredDirection.normalized) + 1) / 2; |
|
|
float forwardRatio = (Vector3.Dot(transform.forward, m_desiredDirection.normalized) + 1) / 2; |
|
|
float speed = m_turnRadius.Evaluate(forwardRatio) * m_playerSpeed; |
|
|
float speed = m_turnRadius.Evaluate(forwardRatio) * m_playerSpeed; |
|
|
m_legAnimator.SetFloat("Movement", speed); |
|
|
m_legAnimator.SetFloat("Movement", speed); |
|
@ -70,7 +68,7 @@ public class PlayerInputController : InputBehaviour |
|
|
if (!m_recievedInput) |
|
|
if (!m_recievedInput) |
|
|
return; |
|
|
return; |
|
|
|
|
|
|
|
|
m_controller.Move(transform.forward * speed * Time.deltaTime); |
|
|
|
|
|
|
|
|
m_controller.Move(transform.forward.normalized * speed * Time.deltaTime); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void LockAxis(Vector3 axis) |
|
|
private void LockAxis(Vector3 axis) |
|
|