Skip to content

Commit

Permalink
bugifx camera
Browse files Browse the repository at this point in the history
  • Loading branch information
ikpil committed Dec 2, 2023
1 parent f9363ce commit 89a5994
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions src/UniRecast.Unity/Assets/Plugins/UniRecast/Runtime/UniRcCamera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ public static class KeyModState

public class UniRcCamera : MonoBehaviour
{
private float camSens = 0.25f;

private Vector3 lastMouse;
private Vector3 lastMousePosition;

// input
private int _modState;
Expand All @@ -36,33 +34,32 @@ private void Update()

private void UpdateMouse(float dt)
{

// left button
if (Input.GetMouseButton(0))
{
Debug.Log("0");
}

// right button
if (Input.GetMouseButtonDown(1))
{
lastMouse = Input.mousePosition;
lastMousePosition = Input.mousePosition;
}

if (Input.GetMouseButton(1))
{
lastMouse = Input.mousePosition - lastMouse;
lastMouse = new Vector3(-lastMouse.y * camSens, lastMouse.x * camSens, 0);
lastMouse = new Vector3(transform.eulerAngles.x + lastMouse.x, transform.eulerAngles.y + lastMouse.y, 0);
transform.eulerAngles = lastMouse;
lastMouse = Input.mousePosition;
// delta
var tempMousePosition = Input.mousePosition;
var delta = tempMousePosition - lastMousePosition;
lastMousePosition = tempMousePosition;

transform.Rotate(Vector3.up, delta.x * 0.25f, Space.World);
transform.Rotate(Vector3.left, delta.y * 0.25f, Space.Self);
}

// wheel button
if (Input.GetMouseButton(2))
{
Debug.Log("2");
}

}

private float GetKeyValue(KeyCode key1, KeyCode key2)
Expand Down

0 comments on commit 89a5994

Please sign in to comment.