- Home /
 
              This question was 
             closed Aug 23, 2021 at 03:14 PM by 
             ILLUSION2006 for the following reason: 
             
 
            OtheI fixed issuer
 
               Question by 
               ILLUSION2006 · Aug 11, 2021 at 04:09 AM · 
                androidrotationscripting problemmobilerotate object  
              
 
              Controls work fine on PC, but not on android phone.
So, I have this script attached to a gun, which should rotate the gun in the same direction as the way the player moves the mobile/on-screen joystick. While this works perfectly in the Unity Game View (On PC) when I build the project to test it out on an android device, the rotation is inverted. (Pulling down on the joystick makes the gun rotate up, and vice, versa.)
Gun Rotation Script:
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class GunMovment : MonoBehaviour
 {
     public Joystick joystick;
 
     void Update()
     {
         Vector3 moveVector = (Vector3.up * joystick.Horizontal + Vector3.left * joystick.Vertical);
         if (joystick.Horizontal != 0 || joystick.Vertical != 0)
         {
             transform.rotation = Quaternion.LookRotation(Vector3.forward, moveVector);
         }
     }
 }
 
              
               Comment