Android Sensor Tutorial – Shake Sensor

Hi Guys, this is the second tutorial for Android Sensor Plugin for Unity3d and here again we will show you on how easy to use it, so let’s do it.

First always check if you have a Android Manifest File on “Assets/Plugins/Android” Directory without it your app won’t work or it will crashed.

If you have an Android Manifest  File  on the correct directory ( “Assets/Plugins/Android” ) , open it and check if you have this permission

After that setup we can now start coding

First we need to get the instance of  Shake Plugin

Then Set the Debug to 0 to hide the debug toast messages else pass 1 to show debug toast messages

And then we need to initialized it.

and of course don’t forget to Setup a Listener for Shake Sensor Callback event

And Then  we start Registering Listener for Shake Sensor

To modify sensitivity just call SetSensitivity method and pass value that you want the range is 0 to 2000

To Modify Update Interval just call SetDelayUpdate and pass value that you want the range is 0 to 1000

If you are done using Shake sensor just call RemoveSensorListener method

And here’s the  exact code used in our  Shake demo scene

Note: this code needs Text and Slider , just create 4 Text UI and 2 slider inside Uniy3d and drag it on this code Inspector and don’t forget to assign the events for slider.

And That’s it we are done, thank you for reading and happy coding 🙂

For more questions or comments or suggestions just email us at gigadrillgames@gmail.com

Android Sensor Tutorial – Pedometer

Note: we just updated the Pedometer Plugin and we added lots of new features for more information on this features and changes please follow this link

http://www.gigadrillgames.com/2017/04/16/pedometer-plugin-version-1-5-for-unity3d/

After Reading that new changes and feature you can still read this but take note this is a bit old now , but don’t inside our plugin there’s a simple demo that is super easy to follow 🙂

Hi Everyone, we just released an Android Sensor Plugin for Unity3d and this time it’s about sensors and the first feature is Pedometer also known as Step Counter

for more info about Step Counter follow this link https://developer.android.com/reference/android/hardware/Sensor.html#TYPE_STEP_COUNTER

for more info about step detector follow this link https://developer.android.com/reference/android/hardware/Sensor.html#TYPE_STEP_DETECTOR

 

and now we will show you on how to easily use this plugin in no time

Quick note: this plugin will only work if your android device supports this features step detector, step counter and accelerometer without this features it will not work so read this first before purchasing the plugin.

so let’s start.

First Android Manifest Requirements

you need to have this permissions on your android manifest file, found in “Assets/Plugins/Android” directory

After checking that you have Android Manifest file in “Assets/Plugins/Android” directory and you have the required permissions it’s to start coding in C# scripts

First you need to have access on PedometerPlugin instance

Then we set Debug to 1 to see toast Debug messages or 0 to hide them

After that we need to initialize it

Then after that if you want to start on Step zero always pass true on SetAlwaysStartAtZero else if you want to continue step count just pass false

Then we need to setup listener for event callback of pedometer

And Then we start pedometer from listening on step sensor

if you want to reset step call ResetTotalStep

when  you are done using pedometer plugin call RemoveSensorListener method

To See all working codes here’s the exact code inside Pedometer Demo

Note: this code needs Text , just create 2 Text UI inside Uniy3d and drag it on this code Inspector.

Hooray we are done , that’s it i hope i should be clear now how to use it.

For Questions or comments or suggestions or any feed back just email us at gigadrillgames@gmail.com

Android Sensor FAQ (Frequently Asked Questions)

Android Sensor FAQ (Frequently Asked Questions)

 

Question:  Why after my first walk the step didn’t count?

Answer:  Because the step sensor and counter needs to calibrate first it needs to get the first cycle of your walking it remembers the speed and your movement  first then if it’s done calibrating it will starts to count.

 

Question: How to start on zero step when starting my game?

Answer:  all you have to do  is call this method and pass true
pedometerPlugin.SetAlwaysStartAtZero(true);

 

Question: How to prevent step from restarting to zero step when restarting the game or application?

Answer:  all you have to do  is call this method and pass false
pedometerPlugin.SetAlwaysStartAtZero(false);

 

Question: What is Step Detect Event for?

Answer: this event is fired to tell you that step is detected

 

Question: I didn’t shake my device at all but shake is detected and counting what is happening, please explain?

Answer: this happened because you set your sensitivity to a very low value try to  increase it to lessen the sensitivity try something like  1100 this is optimize value based on our test.

 

Question: Shake is not detected even if i shake it very strong why?

Answer: this happened because you set your sensitivity to a very High value try to  decrease it to make it more sensitive try something like  1100 this is the optimized value based on our test.

 

Question: Shake is not updating and detected at all why?

Answer: please check delay update, maybe you set it way to high, try something 150 this is the optimized value based on our test. it updates every 0.15 seconds.

 

 

for more questions just email us at gigadrillgames@gmail.com

Android Sensor Tutorials

Hi Guys, here’s the list of Tutorials for Android Sensor Plugin for Unity3d, enjoy reading!

Pedometer or Step Counter Sensor

http://www.gigadrillgames.com/2015/08/24/android-sensor-tutorial-pedometer/

Shake Sensor

http://www.gigadrillgames.com/2015/08/24/android-sensor-tutorial-shake-sensor/

For questions or comments or suggestions or any feed back just email us at gigadrillgames@gmail.com

Android Sensor for Unity3d

Hi Every one, we just made a new Android plugin for Unity3d and this is called Android Sensor this will help you access sensor features on Android devices with in unity3d.

Features:

1. Step Counter also Known as Pedometer
2. Shake Detector using Acceleration

And more possible features to be added in the future!

“The step counter sensor provides the number of steps taken by the user since the last reboot while the sensor was activated. The step counter has more latency (up to 10 seconds) but more accuracy than the step detector sensor.”

“The step detector sensor triggers an event each time the user takes a step. The latency is expected to be below 2 seconds.”

“The Android platform provides several sensors that let you monitor the motion of a device. Two of these sensors are always hardware-based (the accelerometer and gyroscope), and three of these sensors can be either hardware-based or software-based (the gravity, linear acceleration, and rotation vector sensors). For example, on some devices the software-based sensors derive their data from the accelerometer and magnetometer, but on other devices they may also use the gyroscope to derive their data. Most Android-powered devices have an accelerometer, and many now include a gyroscope. The availability of the software-based sensors is more variable because they often rely on one or more hardware sensors to derive their data.”

this information came from this link, if you want to know more about this sensors just follow the link below.

http://developer.android.com/guide/topics/sensors/sensors_motion.html

Note: based on this documentation from http://developer.android.com it self this sensors is not really 100% accurate because it is always depends on your mobile phone hardware or software. so don’t blame us when you are not getting a 100% accurate results.

Before purchasing try it first, here’s the demo link

https://drive.google.com/file/d/0Bw14w3QBZaGxS1NSaHhFRXg5TlU/view?usp=sharing

For questions or comments or suggestions or any feed back just email us at  gigadrillgames@gmail.com