protected void FixedUpdate() { //drag to decrease horizontal velocity if (Mathf.Abs(horizontalVelocity) > 0.00001f) { horizontalVelocity -= DRAG * horizontalVelocity; } //get input; add it to horizontal velocity if (CameraInputController.cameraInput) { moveHorizontal = CameraInputController.GetAxisRaw() * BASE_CAMERA_TURN_ACCELERATION; //Debug.Log(CameraInputController.GetAxisRaw()); } else { //Debug.Log(Input.GetAxisRaw("Horizontal")); moveHorizontal = Input.GetAxisRaw("Horizontal") * BASE_TURN_ACCELERATION; } horizontalVelocity += moveHorizontal * speedModifier; //apply velocity to player rb.velocity = new Vector3(horizontalVelocity, 0, forwardVelocity); //accelerate over time speedModifier += SPEED_UP; forwardVelocity = BASE_SPEED * speedModifier * cameraModifier; //generate cubes in front of the player if (Random.Range(0f, 10f) / forwardVelocity < CubeController.SPAWN_FREQUENCY) { CubeController.GenerateCube(prefabCube, tf.position); } }