Coder Social home page Coder Social logo

hbollon / gyroscopecontrol Goto Github PK

View Code? Open in Web Editor NEW
27.0 4.0 5.0 17 KB

๐ŸŒ€ Unity script used for smooth and customizable object rotation with gyroscope (initially configured to rotate x and z axis using x and y axis of gyro but can be easily edited). It include initial calibration with offset, rotation speed (Time.deltaTime * velocity), smoothing parameter editable in Unity inspector and debug overlay.

License: MIT License

C# 100.00%
unity unity-script csharp physics gyroscope rotation unity3d unity3d-script unity-gyroscope android unity-android

gyroscopecontrol's Introduction

GyroscopeControl : Unity script for object rotation on mobile devices with gyroscope

Unity script used for smooth and customizable object rotation with gyroscope (initially configured to rotate x and z axis using x and y axis of gyro but can be easily edited). It includes initial calibration with offset, rotation speed (Time.deltaTime * velocity), smoothing parameter editable in Unity inspector and debug overlay.

This script has been designed to be easily customizable and to obtain the smoothest and most flexible rotation possible. Tested on Android.

Edit rotation axis

In order to personalize this script to match with your case, you just have to change which gyroscope axis control which object one. To do that, you have to edit the ApplyGyroRotation function :

Quaternion tempGyroRotation = new Quaternion(
    offsetRotation.x * curSpeed, 
    0f * curSpeed, 
    offsetRotation.y * curSpeed, 
    offsetRotation.w * curSpeed
);

Settings

This script contain few parameters editable through Unity inspector :

  • Speed : change rotation speed of the object
  • Smoothing : must be between 0 and 1, it changes the delay for the object in order to reach its final position
  • Wait Gyro Initialization : used to enable or disable the initial delay to wait gyroscope activation
  • Wait Gyro Initialization Duration : duration of the initial delay in seconds
  • Debug : displays an overlay which includes a lot of information such as: real-time gyro attitude, offset, initial position ect...

๐Ÿค Contributing

Contributions, issues and feature requests are welcome!
Feel free to check issues page.

Show your support

Give a โญ๏ธ if this project helped you!

gyroscopecontrol's People

Contributors

efferifick avatar hbollon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.