// Update is called once per frame void Update() { if (!doMove) { return; } if (NInput.TouchBegan()) { Joystick.SetPivot(); PlayerPos = Player.localPosition; } if (NInput.TouchEnded()) { } if (NInput.IsScreenTouched()) { Speed += Time.deltaTime * Acceleration; Joystick.Update(); } else { Speed -= Time.deltaTime * Acceleration * 2f; } Speed = Mathf.Clamp(Speed, MinSpeed, !IsInFastLane() ? MaxSpeed : MaxSpeed + FewerBoost); Dist += Time.deltaTime * Speed; if (Dist >= Track.length) { dist = 30f; } SetPositionOnDistance(); if (isFewer) { Trail.emitting = true; if (Time.time > NextSpeedUp) { FewerBoost += 10f; Speed += 10f; NextSpeedUp = Time.time + 2f; } } else { FewerBoost = 20f; Trail.emitting = false; } }
// Update is called once per frame void FixedUpdate() { bool isTouchingGround = CarManager.CheckGround(2.5f); if (isTouchingGround) { TimeSinceLanded += Time.deltaTime; } else { TimeSinceLanded = 0f; } if (Input) { Joystick.Update(); float mag = Joystick.GetMagnitude() / 20f; float roadWidth = LevelGenerator.instance.RoadWidth / 2f; CarManager.MoveSideways(PlayerPos.x + mag); if (isTouchingGround) { CarManager.Torque = 0f; if (CarManager.Flips > 0 && TimeSinceLanded < 1.5f) { StartCoroutine(BoostPlayer()); } CarManager.Flips = 0; CarManager.MoveForward(); } else { CarManager.Rotate(); } } }