public void Swipe() { if (Input.GetMouseButtonDown(0)) { firstPressPos = new Vector2(Input.mousePosition.x, Input.mousePosition.y); } if (Input.GetMouseButtonUp(0)) { secondPressPos = new Vector2(Input.mousePosition.x, Input.mousePosition.y); currentSwipe = new Vector2(secondPressPos.x - firstPressPos.x, secondPressPos.y - firstPressPos.y); currentSwipe.Normalize(); if (!(secondPressPos == firstPressPos)) { if (Mathf.Abs(currentSwipe.x) > Mathf.Abs(currentSwipe.y)) { ParentTutSwipe.SetActive(false); PlayerPrefs.SetInt(Constants.Tutors + "4", 1); audioSource.clip = ClipSwipe; audioSource.Play(); if (currentSwipe.x < 0) { directCar = DirectCar.Left; } else { directCar = DirectCar.Right; } } else { if (currentSwipe.y < 0) { // Swipe Down } else { //Swipe Up } } } } }
private void Update() { if (!IsStopped) { if (Physics.Raycast(Ray.position, Ray.forward, out hit, 14f)) { if (hit.collider) { SpeedMove = 0; } else { SpeedMove = StartSpeed; } } else { SpeedMove = StartSpeed; } if (IsSpeedCar) { if (Physics.Raycast(Ray.position, Ray.forward, out hit, 18f)) { if (hit.collider) { if (Reset == 0) { audioSource.clip = ClipFapFap; audioSource.Play(); if (directCar == DirectCar.Right) { directCar = DirectCar.Left; } if (directCar == DirectCar.Left) { directCar = DirectCar.Right; } Reset = 1; Invoke("InvokeReset", 1.8f); } } } if (directCar == DirectCar.Left) { this.transform.position = Vector3.Lerp(this.transform.position, new Vector3(11.2f, this.transform.position.y, this.transform.position.z), SpeedDirect * Time.deltaTime); } if (directCar == DirectCar.Right) { this.transform.position = Vector3.Lerp(this.transform.position, new Vector3(-10.1f, this.transform.position.y, this.transform.position.z), SpeedDirect * Time.deltaTime); } } switch (directionWorld) { case DirectionWorld.Forward: UpdateMoveCar(Vector3.forward); break; case DirectionWorld.Back: UpdateMoveCar(-Vector3.forward); break; } WheelRF.Rotate(Vector3.forward * (Time.deltaTime * SpeedWheel * 10f)); WheelLF.Rotate(Vector3.forward * (Time.deltaTime * SpeedWheel * 10f)); WheelBL.Rotate(Vector3.forward * (Time.deltaTime * SpeedWheel * 10f)); WheelBR.Rotate(Vector3.forward * (Time.deltaTime * SpeedWheel * 10f)); } }