Skip to content

Commit

Permalink
Improved rotated around feature
Browse files Browse the repository at this point in the history
  • Loading branch information
szylis committed Jan 23, 2024
1 parent 08728a8 commit 4cbc08e
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions Assets/AWSIM/Scripts/FollowCamera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,16 @@ public class FollowCamera : MonoBehaviour

[Space(10)]
[Header("Camera Zoom")]
[Tooltip("Sensitivity of camera zoom")]
[Tooltip("Mouse scroll wheel sensitivity for camera zoom")]
public float ZoomSensitivity = 10f;

[Space(10)]
[Header("Camera Rotate Around")]
[Tooltip("Toggle key between rotate around mode and follow mode")]
public KeyCode RotateAroundModeToggle = KeyCode.C;

[Tooltip("Maximum camera rotation speed around the target")]
public float MaxRotateAroundSpeed = 64.0f;

[Tooltip("Mouse movement sensitivity for camera rotation around the target")]
public float RotateAroundSensitivity = 32.0f;

#endregion

Expand Down Expand Up @@ -91,13 +90,11 @@ void Update()
// rotate around when mouse middle button is held down
if (Input.GetMouseButton(2))
{
if (Input.GetAxis("Mouse X") < 0)
{
rotateAroundSpeed = MaxRotateAroundSpeed;
}
else if (Input.GetAxis("Mouse X") > 0)
float mouseHorzAxis = Input.GetAxis("Mouse X");

if(Mathf.Abs(mouseHorzAxis) > 0.01f)
{
rotateAroundSpeed = MaxRotateAroundSpeed * -1f;
rotateAroundSpeed = RotateAroundSensitivity * mouseHorzAxis;
}
else
{
Expand Down

0 comments on commit 4cbc08e

Please sign in to comment.