#if UNITY_EDITOR // Smoothly tilts a transform towards a target rotation. float tiltAroundY = -Input.GetAxis("Horizontal") * tiltAngle float tiltAroundX = Input.GetAxis("Vertical") * tiltAngle // Rotate the cube by converting the angles into a quaternion. Quaternion target = Quaternion.Euler(tiltAroundX, tiltAroundY, 0); // Dampen towards the target rotation transform.rotation = Quaternion.Slerp(transform.rotation, target, Time.deltaTime* smooth); #else float tiltAroundY = -Input.acceleration.x * tiltAngle float tiltAroundX = Input.acceleration.y * tiltAngle Quaternion target = Quaternion.Euler(tiltAroundX, tiltAroundY, 0); transform.rotation = Quaternion.Slerp(transform.rotation, target, Time.deltaTime * smooth); #endif