Rotating a GameObject in Unity3D using the gyroscope

June 24, 2014
2 min read

Games are the most entertaining activities that we can do on a PC or a mobile device. From the simple mouse and keyboard on a PC to the touch screen and sensors of a mobile device. This post is here to explain how to implement an aiming system to a mobile game development project. Attached you have the script, just attach it to your camera and you are ready to go.

For those familiar to Unity, this is a usual check up done in the Awake() function to verify if the device has a gyroscope sensor or if the application is running in the editor. Future updated will contain this functionality on Android and Windows devices, for now is just for iOS devices.


//check if the gyro is enabled
#if UNITY_IPHONE
    if(Input.gyro.enabled){
        enabledGyro = true;

        //debug
        ToDebug("Gyro Enabled");
    } else {
        //TODO: show a warning message
    }
#endif

#if UNITY_ANDROID
    //TODO : Android Gyro Version
#endif

#if UNITY_WINDOWS_PHONE
    //TODO : Windows Phone Gyro Version
#endif

#if UNITY_EDITOR 
    ToDebug("No gyro in the Unity Editor");
#endif

“x” and “y” holds the rotation rates from the gyro which will be filtered and normalized for future use.


//get values from the gyroscope
x = Input.gyro.rotationRate.x;
y = Input.gyro.rotationRate.y;

After the values from the gyro are normalized two function will use these values, one for the X rotation axis or up and down and one for Y rotation or left and right.


//rotate the camera up and down(x rotation)
function RotateUpDown(axis : float){
	transform.RotateAround(transform.position , transform.right, -axis * Time.deltaTime * gyroSensitivity);
}

//rotate the camera rigt and left (y rotation)
function RotateRightLeft(axis : float){
 	transform.RotateAround(transform.position, Vector3.up, -axis * Time.deltaTime * gyroSensitivity);
}

For more information download the script file and follow the comments in the code.

→ If you want to find out more about the author of the article click play on the below video.

Share on:

Want to stay on top of everything?

Get updates on industry developments and the software solutions we can now create for a smooth digital transformation.

* I read and understood the ASSIST Software website's terms of use and privacy policy.

Frequently Asked Questions

1. What is ASSIST Software's development process?  

The Software Development Life Cycle (SDLC) we employ defines the following stages for a software project. Our SDLC phases include planning, requirement gathering, product design, development, testing, deployment, and maintenance.

2. What software development methodology does ASSIST Software use?  

ASSIST Software primarily leverages Agile principles for flexibility and adaptability. This means we break down projects into smaller, manageable sprints, allowing continuous feedback and iteration throughout the development cycle. We also incorporate elements from other methodologies to increase efficiency as needed. For example, we use Scrum for project roles and collaboration, and Kanban boards to see workflow and manage tasks. As per the Waterfall approach, we emphasize precise planning and documentation during the initial stages.

3. I'm considering a custom application. Should I focus on a desktop, mobile or web app?  

We can offer software consultancy services to determine the type of software you need based on your specific requirements. Please explore what type of app development would suit your custom build product.   

  • A web application runs on a web browser and is accessible from any device with an internet connection. (e.g., online store, social media platform)   
  • Mobile app developers design applications mainly for smartphones and tablets, such as games and productivity tools. However, they can be extended to other devices, such as smartwatches.    
  • Desktop applications are installed directly on a computer (e.g., photo editing software, word processors).   
  • Enterprise software manages complex business functions within an organization (e.g., Customer Relationship Management (CRM), Enterprise Resource Planning (ERP)).

4. My software product is complex. Are you familiar with the Scaled Agile methodology?

We have been in the software engineering industry for 30 years. During this time, we have worked on bespoke software that needed creative thinking, innovation, and customized solutions. 

Scaled Agile refers to frameworks and practices that help large organizations adopt Agile methodologies. Traditional Agile is designed for small, self-organizing teams. Scaled Agile addresses the challenges of implementing Agile across multiple teams working on complex projects.  

SAFe provides a structured approach for aligning teams, coordinating work, and delivering value at scale. It focuses on collaboration, communication, and continuous delivery for optimal custom software development services. 

5. How do I choose the best collaboration model with ASSIST Software?  

We offer flexible models. Think about your project and see which models would be right for you.   

  • Dedicated Team: Ideal for complex, long-term projects requiring high continuity and collaboration.   
  • Team Augmentation: Perfect for short-term projects or existing teams needing additional expertise.   
  • Project-Based Model: Best for well-defined projects with clear deliverables and a fixed budget.   

Contact us to discuss the advantages and disadvantages of each model. 

ASSIST Software Team Members

Sehen Sie die Vergangenheit, Gegenwart und Zukunft der Technologie mit den Augen eines erfahrenen rumänischen Unternehmens für kundenspezifische Software. Der ASSIST Insider-Newsletter beleuchtet Ihren Weg zur digitalen Transformation.

* Ich habe die Nutzungsbedingungen und Datenschutzrichtlinien der ASSIST Software-Website gelesen und verstanden.

Folgen Sie uns

© 2025 ASSIST-Software. Alle Rechte vorbehalten. Mit Liebe entworfen.