I am developing an car game for android with an UI steering wheel to control the car. I'm following Answer example for the wheel rotation. This is the code to rotate the wheel.

rectT.localEulerAngles = Vector3.back * wheelAngle;

This code working completely fine in unity and in the portrait mode of actual device.

But in the landscape modeof actual devices , the rotation get inverted. Please help me to solve this problem. Thank you


You could maybe detect the orientation of the device and if its in landscape mode, it spins in the other direction.

if (portraitMode) {
   rectT.localEulerAngles = Vector3.back * wheelAngle;
} else {
   if (landscapeMode) {
       rectT.localEulerAngles = Vector3.forward * wheelAngle;
| improve this answer | |
  • \$\begingroup\$ This answer lacks information about how one detects landscape or portrait mode in Unity. \$\endgroup\$ – Philipp Aug 27 at 11:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.