// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { if (!gameHasStarted) { startGame.Invoke(); gameHasStarted = true; animationController.playIdleToRun(); tutorialUIRef.SetActive(false); } } if (Input.GetMouseButton(0)) { swipeContRef.CalculateDistance(Input.mousePosition); newXPos = Mathf.Clamp(transform.position.x + swipeContRef.normalizedDistance * xSpeed, startXPos + clampVals.x, startXPos + clampVals.y); //Rotate if ((transform.rotation.y >= 0 && (swipeContRef.normalizedDistance >= 0.1f)) || (transform.rotation.y <= 0 && swipeContRef.normalizedDistance <= -0.1f)) { rotationLerper += Time.deltaTime * rotationLerpSpeed; if (rotationLerper > 1) { rotationLerper = 1; } RotateCharacter(swipeContRef.normalizedDistance >= 0.1f, rotationLerper, swipeContRef.normalizedDistance * 30); } else { rotationLerper -= Time.deltaTime * rotationLerpSpeed; if (rotationLerper < 0) { rotationLerper = 0; } RotateCharacter(transform.rotation.y > 0, rotationLerper, swipeContRef.normalizedDistance * 30); } } else { newXPos = transform.position.x; //Rotate rotationLerper -= Time.deltaTime * rotationLerpSpeed; if (rotationLerper < 0) { rotationLerper = 0; } RotateCharacter(transform.rotation.y > 0, rotationLerper, swipeContRef.normalizedDistance * 30); } }