input refactored

This commit is contained in:
Mausham
2025-12-15 21:51:34 +05:45
parent a166fe2861
commit 05287c4b73
10 changed files with 41 additions and 25 deletions

View File

@@ -8,7 +8,9 @@ public class PlatformManager : MonoBehaviour,IPlatformManager
private float yPos = 0f;
public float rotSpeed = 5f;
private float rotAmount;
private float targetRotAmount;
private float smoothRotAmount;
private void Start()
{
@@ -26,7 +28,18 @@ public class PlatformManager : MonoBehaviour,IPlatformManager
}
private void LateUpdate()
{
transform.Rotate(Vector3.up * rotAmount);
#if UNITY_EDITOR || UNITY_STANDALONE
if (!inputReader.isMouseButtonPressed) return;
#endif
smoothRotAmount = Mathf.MoveTowards(
smoothRotAmount,
targetRotAmount,
Time.deltaTime * 80f
);
transform.Rotate(Vector3.up * smoothRotAmount, Space.World);
}
void ShowPlatforms()
{
@@ -47,18 +60,11 @@ public class PlatformManager : MonoBehaviour,IPlatformManager
private void HandleDrag(Vector2 drag)
{
rotAmount = -drag.normalized.x * rotSpeed;
float raw = drag.x / Screen.width;
//#if UNITY_EDITOR || UNITY_STANDALONE
// if (!inputReader.isMouseButtonPressed) return;
// transform.Rotate(Vector3.up * rotAmount);
//#elif UNITY_IOS || UNITY_ANDROID
// transform.Rotate(Vector3.up * rotAmount * DPI);
//#endif
//transform.Rotate(Vector3.up * rotAmount);
targetRotAmount = -raw * rotSpeed * 180f;
targetRotAmount = Mathf.Clamp(targetRotAmount, -10f,10f);
}
}