0
\$\begingroup\$

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

\$\endgroup\$
1

1 Answer 1

-1
\$\begingroup\$

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;
   }
}
\$\endgroup\$
1
  • \$\begingroup\$ This answer lacks information about how one detects landscape or portrait mode in Unity. \$\endgroup\$
    – Philipp
    Aug 27, 2020 at 11:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .