Skip to content

Commit

Permalink
Fixed Drag Move bug with mouse position
Browse files Browse the repository at this point in the history
  • Loading branch information
Nickk888SAMP committed Jul 16, 2024
1 parent 3fc2145 commit f57ea8a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1260,13 +1260,14 @@ MonoBehaviour:
AllowTiltRotate: 1
AllowZoom: 1
AllowDragMove: 1
mouseDragStyle: 0
AllowKeysMove: 1
AllowScreenSideMove: 1
AllowHeightOffsetChange: 1
MouseLockOnRotate: 1
InvertMouseVertical: 0
InvertMouseHorizontal: 0
CameraMouseSpeed: 2
CameraMouseSpeed: 16
CameraRotateSpeed: 2
CameraKeysRotateSpeedMultiplier: 50
CameraKeysSpeed: 6
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,7 @@ MonoBehaviour:
MouseLockOnRotate: 1
InvertMouseVertical: 0
InvertMouseHorizontal: 0
CameraMouseSpeed: 8
CameraMouseSpeed: 16
CameraRotateSpeed: 2
CameraKeysRotateSpeedMultiplier: 50
CameraKeysSpeed: 6
Expand Down
4 changes: 2 additions & 2 deletions Assets/Nickk888/RTSCameraController/Scenes/ExampleScene.unity
Git LFS file not shown
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ [SerializeField] [Tooltip("Invert the horizontal mouse input?")]

[Space] [Header("Speed")]
[SerializeField, Min(0)]
public float CameraMouseSpeed = 8.0f;
public float CameraMouseSpeed = 16.0f;

[SerializeField, Min(0)]
public float CameraRotateSpeed = 2.0f;
Expand Down Expand Up @@ -378,13 +378,13 @@ private void HandleMouseDrag(Vector3 mousePos)
CancelTargetLock();
OnMouseDragStarted?.Invoke(this, new OnMouseDragStartedEventArgs { mouseLockPosition = mousePos, mouseDragStyle = MouseDragStyle.MouseDirection });
}
if ((_isDragging && !_inputProvider.DragButtonInput()) || (_isDragging && !AllowDragMove))
else if ((_isDragging && !_inputProvider.DragButtonInput()) || (_isDragging && !AllowDragMove))
{
Cursor.visible = true;
_isDragging = false;
OnMouseDragStopped?.Invoke(this, EventArgs.Empty);
}
if (_inputProvider.DragButtonInput() && _isDragging && AllowDragMove)
else if (_inputProvider.DragButtonInput() && _isDragging && AllowDragMove)
{
Vector3 vectorChange = new Vector3(_mouseLockPos.x - mousePos.x, 0, _mouseLockPos.y - mousePos.y) * -1;
float distance = vectorChange.sqrMagnitude;
Expand All @@ -407,14 +407,14 @@ private void HandleMouseDrag(Vector3 mousePos)
CancelTargetLock();
OnMouseDragStarted?.Invoke(this, new OnMouseDragStartedEventArgs { mouseLockPosition = mousePos, mouseDragStyle = MouseDragStyle.Direct });
}
if ((_isDragging && !_inputProvider.DragButtonInput()) || (_isDragging && !AllowDragMove))
else if ((_isDragging && !_inputProvider.DragButtonInput()) || (_isDragging && !AllowDragMove))
{
Cursor.visible = true;
Cursor.lockState = CursorLockMode.None;
_isDragging = false;
OnMouseDragStopped?.Invoke(this, EventArgs.Empty);
}
if (_inputProvider.DragButtonInput() && _isDragging && AllowDragMove)
else if (_inputProvider.DragButtonInput() && _isDragging && AllowDragMove)
{
Vector3 vectorChange = _inputProvider.MouseInput();
vectorChange.z = vectorChange.y;
Expand Down

0 comments on commit f57ea8a

Please sign in to comment.