- Home /
C# GameObject Reverses Z Rotation
I have a script that is suppose to make a gameobject rotate along the Z axis towards the mouse. However when I rotate the gameobject somewhere between 70 and 120 degrees it reverses it's rotation. I'm not sure why as I haven't given my script that kind of functionality. Any idea how I can fix this?
 using UnityEngine;
 using System.Collections;
 
 public class Rotate : MonoBehaviour {
     public float sensitivityZ = 15;
     
     void Update () {
             float rotationZ = Input.GetAxis("Mouse Z") * sensitivityZ;
             transform.RotateAroundLocal( gameObject.transform.forward,Mathf.Deg2Rad * rotationZ );
     }
 }
 
 
Transform.RotateAroundLocal is a deprecated function, use Transform.Rotate with the Space parameter set to Space.Self ins$$anonymous$$d. Also, when I tried using "$$anonymous$$ouse Z" as an axis in Unity I got an error; is that custom-defined?
Your answer
 
 
             Follow this Question
Related Questions
C# Rotate GameObjects Regardless of List Size 2 Answers
C# Function Transform to Gameobject Convert 1 Answer
C# Need Help Refining Ricochet Script 1 Answer
C# Make Child Not Animate Looped Animation 1 Answer
C# GameObjectList not Setting Parent 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
               
 
			 
                