input refactored
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user