|
|
|
|
|
|
public float m_LookSpeedController = 120f; |
|
|
|
public float m_LookSpeedMouse = 10.0f; |
|
|
|
public float m_MoveSpeed = 10.0f; |
|
|
|
public float m_MoveSpeedIncrement = 2.5f; |
|
|
|
public float m_Turbo = 10.0f; |
|
|
|
|
|
|
|
private static string kMouseX = "Mouse X"; |
|
|
|
|
|
|
private static string kVertical = "Vertical"; |
|
|
|
private static string kHorizontal = "Horizontal"; |
|
|
|
|
|
|
|
private static string kYAxis = "YAxis"; |
|
|
|
private static string kSpeedAxis = "Speed Axis"; |
|
|
|
|
|
|
|
void OnEnable() |
|
|
|
{ |
|
|
|
RegisterInputs(); |
|
|
|
|
|
|
{ |
|
|
|
#if UNITY_EDITOR
|
|
|
|
List <InputManagerEntry> inputEntries = new List<InputManagerEntry>(); |
|
|
|
List<InputManagerEntry> inputEntries = new List<InputManagerEntry>(); |
|
|
|
inputEntries.Add(new InputManagerEntry { name = kYAxis, kind = InputManagerEntry.Kind.KeyOrButton, btnPositive = "page up", altBtnPositive = "joystick button 5", btnNegative = "page down", altBtnNegative = "joystick button 4", gravity = 1000.0f, deadZone = 0.001f, sensitivity = 1000.0f }); |
|
|
|
|
|
|
|
inputEntries.Add(new InputManagerEntry { name = kSpeedAxis, kind = InputManagerEntry.Kind.KeyOrButton, btnPositive = "home", btnNegative = "end", gravity = 1000.0f, deadZone = 0.001f, sensitivity = 1000.0f }); |
|
|
|
inputEntries.Add(new InputManagerEntry { name = kSpeedAxis, kind = InputManagerEntry.Kind.Axis, axis = InputManagerEntry.Axis.Seventh, gravity = 1000.0f, deadZone = 0.001f, sensitivity = 1000.0f }); |
|
|
|
|
|
|
|
InputRegistering.RegisterInputs(inputEntries); |
|
|
|
#endif
|
|
|
|
} |
|
|
|
|
|
|
// If the debug menu is running, we don't want to conflict with its inputs.
|
|
|
|
if(DebugMenuManager.instance.menuUI.isEnabled) |
|
|
|
if (DebugMenuManager.instance.menuUI.isEnabled) |
|
|
|
return; |
|
|
|
|
|
|
|
float inputRotateAxisX = 0.0f; |
|
|
|
|
|
|
inputRotateAxisX += (Input.GetAxis(kRightStickX) * m_LookSpeedController * Time.deltaTime); |
|
|
|
inputRotateAxisY += (Input.GetAxis(kRightStickY) * m_LookSpeedController * Time.deltaTime); |
|
|
|
|
|
|
|
float inputChangeSpeed = Input.GetAxis(kSpeedAxis); |
|
|
|
if (inputChangeSpeed != 0.0f) |
|
|
|
{ |
|
|
|
m_MoveSpeed += inputChangeSpeed * m_MoveSpeedIncrement; |
|
|
|
if (m_MoveSpeed < m_MoveSpeedIncrement) m_MoveSpeed = m_MoveSpeedIncrement; |
|
|
|
} |
|
|
|
|
|
|
|
float inputYAxis = Input.GetAxis(kYAxis); |
|
|
|
bool moved = inputRotateAxisX != 0.0f || inputRotateAxisY != 0.0f || inputVertical != 0.0f || inputHorizontal != 0.0f; |
|
|
|
bool moved = inputRotateAxisX != 0.0f || inputRotateAxisY != 0.0f || inputVertical != 0.0f || inputHorizontal != 0.0f || inputYAxis != 0.0f; |
|
|
|
if (moved) |
|
|
|
{ |
|
|
|
float rotationX = transform.localEulerAngles.x; |
|
|
|
|
|
|
moveSpeed *= Input.GetAxis("Fire1") > 0.0f ? m_Turbo : 1.0f; |
|
|
|
transform.position += transform.forward * moveSpeed * inputVertical; |
|
|
|
transform.position += transform.right * moveSpeed * inputHorizontal; |
|
|
|
transform.position += Vector3.up * moveSpeed * inputYAxis; |
|
|
|
} |
|
|
|
} |
|
|
|
} |