-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCursorControl.cs
More file actions
36 lines (24 loc) · 1.29 KB
/
CursorControl.cs
File metadata and controls
36 lines (24 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using UnityEngine;
public class CursorControl : MonoBehaviour {
public bool changeSpeed;
public bool useSmoothing;
public float speed = 0;
public float accel = 0;
private Vector2 velRef;
private Point lastMousePos;
private Vector2 v2ToSet;
private void FixedUpdate() {
if (!changeSpeed)
return;
Vector2 direction = new Vector2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y")).normalized;
//Point cursorSpeed = new Point(Mathf.RoundToInt(direction.x * speed), Mathf.RoundToInt(direction.y * speed));
////Point difference = MouseUtils.GetSystemMousePos() - lastMousePos;
////Point newPos = MouseUtils.GetSystemMousePos() + new Point(Mathf.RoundToInt(difference.x * speed), Mathf.RoundToInt(difference.y * speed));
Point currentMousePosition = MouseUtils.GetSystemMousePos();
//Vector2 targetPos = new Vector2(currentMousePosition.x + cursorSpeed.x, currentMousePosition.y + cursorSpeed.y);
//v2ToSet = Vector2.SmoothDamp(v2ToSet, targetPos, ref velRef, accel);
//StartCoroutine(MouseUtils.SetRelativeMousePosUnconstrained(new Point(Mathf.RoundToInt(v2ToSet.x), Mathf.RoundToInt(v2ToSet.y))));
Point newPoint = currentMousePosition + new Point(Mathf.RoundToInt(direction.x * speed), Mathf.RoundToInt(direction.y * speed));
MouseUtils.SetSystemMousePos(newPoint);
}
}