Code Monkey home page Code Monkey logo

natstep's Introduction

Pedometer API

Pedometer is a native pedometer API for the Unity game engine. The API provides sensor information about step count and distance covered (in meters). It is a minimalist API with native backends on iOS and Android.

Using the API

To use the API, simply create a Pedometer instance:

// Create a pedometer
// The OnStep callback will be invoked each time a step is detected
var pedometer = new Pedometer(OnStep);

void OnStep (int steps, double distance) {
    // Display the values
    stepText.text = steps.ToString();
    // Display distance in feet
    distanceText.text = (distance * 3.28084).ToString("F2") + " ft";
}

When you are done detecting steps from a Pedometer instance, you must dispose it:

// Dispose of this pedometer instance
pedometer.Dispose();

Notes

  • On iOS, you must add an NSMotionUsageDescription key to the Info.plist in Xcode before building. This determines the message used to request pedometer permissions from the user.

Credits

natstep's People

Contributors

akill317 avatar olokobayusuf 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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

natstep's Issues

Find system steps on IOS

Hi,

So I am looking for a way to record steps the user is using everyday. Obviously I can't be calculating on the APP since it will be killed.

Since I know this is possible on ANDROID, I did some modification and managed to get the system stepCount of android based on your plugin. Works very well on all the android phones I have tried with. i.e. user has recorded 10 steps, now opens the app, shows 10 steps, and records 5 more steps, now it shows 15 steps.

However with IOS, I can only read the steps calculated since APP opening.i.e. user has recorded 10 steps, now opens the app, shows 0 steps, and records 5 more steps, now it shows 0 steps.

Any advice? Is IOS capable of getting the same data?

Not able to get Steps count on the demo scene

Hi,
This is to inform you that I am using your plugin in my app to get the step counts. I am trying to get mobile pedometer steps and show the same to my unity app. But unfortunately, I am not getting any response at all. Even I am not getting any errors it is difficult for me to diagnose the problem. It's very urgent for me to show as my app will be incomplete without this. Actually, I am using the same code on my end. Please suggest to me what extra ee can do to achieve this.
I tried running the demo scene in an empty project also but it never increments the step counts.

My device has the inbuilt pedometer,
Device name: One plus 7T, Android v 10
Unity 2019.2.17

public class StepCounter : MonoBehaviour {

    public Text stepText, distanceText;
    private Pedometer pedometer;

    private void Start () {
        // Create a new pedometer
        pedometer = new Pedometer(OnStep);
        // Reset UI
        OnStep(0, 0);
    }

    private void OnStep (int steps, double distance) {
        // Display the values // Distance in feet
        stepText.text = steps.ToString();
        distanceText.text = (distance * 3.28084).ToString("F2") + " ft";
    }

    private void OnDisable () {
        // Release the pedometer
        pedometer.Dispose();
        pedometer = null;
    }
}

}

Expose event timestamps

It would be useful to get information about when a step occured - this is necessary for syncing with other APIs that are also timestamp-based.
As it is now, the steps will rush to the application on wake without information about when they happened.
Both underlying platform APIs seem to expose this property.

Cannot find 'Pedometer'

The type or namespace name 'Pedometer' could not be found (are you missing a using directive or an assembly reference?)

Is there a way to make Step tracking more sensitive?

Hello there, dev. ๐Ÿ˜บ

Please help.

Does the plugin offer a way to make the step tracking/counting more sensitive?
It is because of these following scenarios:

  • It takes a while before the user's steps are counted right after starting the Pedometer.
  • More often than not, while you're walking, you cannot get any Step updates from the plugin in a way that it's per physical step basis. (Example: Current step count is 0, you walk 10 steps. As you take each step, the counter doesn't increase by 1. Instead, the counter just updates itself after the 10th+ step.)

It's really cool that this plugin is free and supports both iOS and Android.
If the step detection could be made more sensitive and this plugin was a paid asset, I'd gladly beg my team to purchase this.

Steps count by tens

From my testing I found that I have to walk around 17 steps for the pedometer to all of a sudden jump from 0 to 10 steps. I was wondering if there was any way to change the number of oscillations needed per step to detect after say, 5 steps. I think the way I just proposed only works if the pedometer API determines steps from the accelerometer data. Does this API analyze accelerometer data or does it use native pedometers in phones? If it is based off native pedometer, what happens when there is no pedometer in the phone, is there a way to first detect if a pedometer is installed and then provide an response if not?

Error with IL2CPP

Greetings,
I'm getting the following error when building the app with IL2CPP selected.
Any ideas why this is happening and what should be done in order to fix it?

`Exception: Failed running C:\Program Files\Unity\Hub\Editor\2020.3.35f1\Editor\Data\il2cpp/build/BeeSettings/offline/bee.exe --no-colors --prebuiltbuildprogram="C:\Program Files\Unity\Hub\Editor\2020.3.35f1\Editor\Data\il2cpp/build/BeeSettings/offline/artifacts/buildprogram/buildprogram.exe"

stdout:
[ ] Require frontend run. tundra.dag no longer valid. FileSignature timestamp changed: il2cpp_settings.json
[ 0s] Executed build program. Created build graph with 2 nodes.
[ 0s] Freezing tundra.dag.json into .dag (.dag file didn't exist)
[BUSY 6s] Il2Cpp E:/UnityProjects/Project/Library/Il2cppBuildCache/Android/arm64-v8a/Native/arm64-v8a/libil2cpp.so
[0/2 8s] Il2Cpp E:/UnityProjects/Project/Library/Il2cppBuildCache/Android/arm64-v8a/Native/arm64-v8a/libil2cpp.so

CommandLine

"C:\Program Files\Unity\Hub\Editor\2020.3.35f1\Editor\Data\il2cpp/build/deploy/netcoreapp3.1/il2cpp.exe" --compile-cpp --libil2cpp-static --platform="Android" --architecture="ARM64" --configuration="Release" --outputpath="E:\UnityProjects\Project\Library\Il2cppBuildCache\Android\arm64-v8a\Native\arm64-v8a\libil2cpp.so" --cachedirectory="E:\UnityProjects\Project\Assets..\Library\il2cpp_android_arm64-v8a/il2cpp_cache" --additional-include-directories="C:/Program Files/Unity/Hub/Editor/2020.3.35f1/Editor/Data/PlaybackEngines/AndroidPlayer/Tools\bdwgc/include" --additional-include-directories="C:/Program Files/Unity/Hub/Editor/2020.3.35f1/Editor/Data/PlaybackEngines/AndroidPlayer/Tools\libil2cpp/include" --additional-libraries="E:/UnityProjects/Project/Assets/Plugins/Pedometer/Plugins/iOS/libPedometer.a" --baselib-directory="C:/Program Files/Unity/Hub/Editor/2020.3.35f1/Editor/Data/PlaybackEngines/AndroidPlayer\Variations\il2cpp\Release\StaticLibs\arm64-v8a" --avoid-dynamic-library-copy --tool-chain-path="C:/Program Files/Unity/Hub/Editor/2020.3.35f1/Editor/Data/PlaybackEngines/AndroidPlayer/NDK" --incremental-g-c-time-slice=3 --profiler-report --map-file-parser="C:/Program Files/Unity/Hub/Editor/2020.3.35f1/Editor/Data/Tools/MapFileParser/MapFileParser.exe" --generatedcppdir=E:/UnityProjects/Project/Library/Il2cppBuildCache/Android/armeabi-v7a/il2cppOutput --stats-output-dir=E:/UnityProjects/Project/Library/Il2cppBuildCache/Android/armeabi-v7a/il2cppStats --dotnetprofile="unityaot"

ExitCode

4

Output

Building libil2cpp.so with AndroidToolChain

Output directory: E:\UnityProjects\Project\Library\Il2cppBuildCache\Android\arm64-v8a\Native\arm64-v8a

Cache directory: E:\UnityProjects\Project\Library\il2cpp_android_arm64-v8a\il2cpp_cache

ObjectFiles: 519 of which compiled: 0

Total compilation time: 652 milliseconds.

Error: Unity.IL2CPP.Building.BuilderFailedException: C:\Program Files\Unity\Hub\Editor\2020.3.35f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++ @"C:\Users\Sebastijan\AppData\Local\Temp\tmpC16.tmp" -o "E:\UnityProjects\Project\Library\il2cpp_android_arm64-v8a\il2cpp_cache\linkresult_750536144EA223428C7430F8D9C54B0D\libil2cpp.so" -shared -Wl,-soname,libil2cpp.so -Wl,--no-undefined -Wl,-z,noexecstack -Wl,--gc-sections -Wl,--build-id -stdlib=libc++ -static-libstdc++ -target aarch64-linux-android21 -Wl,--wrap,sigaction "E:\UnityProjects\Project\Assets\Plugins\Pedometer\Plugins\iOS\libPedometer.a" "C:\Program Files\Unity\Hub\Editor\2020.3.35f1\Editor\Data\PlaybackEngines\AndroidPlayer\Variations\il2cpp\Release\StaticLibs\arm64-v8a\baselib.a" -llog -rdynamic -fuse-ld=bfd.exe

E:\UnityProjects\Project\Assets\Plugins\Pedometer\Plugins\iOS\libPedometer.a: file not recognized: File format not recognized

clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation)

at Unity.IL2CPP.Building.CppProgramBuilder.PostprocessObjectFiles(HashSet`1 objectFiles, CppToolChainContext toolChainContext)

at Unity.IL2CPP.Building.CppProgramBuilder.Build(IBuildStatistics& statistics)

at il2cpp.Compilation.CompilationDriver.Run(RuntimePlatform platform, BuildingOptions buildingOptions, ReadOnlyCollection`1 matchedAssemblyMethodSourceFiles)

at il2cpp.Program.DoRun(String[] args, RuntimePlatform platform, BuildingOptions buildingOptions, Boolean throwExceptions)
*** Bee build failed (8.11 seconds), 1 items updated, 2 evaluated
stderr:

UnityEditorInternal.Runner.RunProgram (UnityEditor.Utils.Program p, System.String exe, System.String args, System.String workingDirectory, UnityEditor.Scripting.Compilers.CompilerOutputParserBase parser) (at :0)
UnityEditorInternal.Runner.RunManagedProgram (System.String exe, System.String args, System.String workingDirectory, UnityEditor.Scripting.Compilers.CompilerOutputParserBase parser, System.Action1[T] setupStartInfo) (at <bfe26bbc7be749c7bb22d52435e15888>:0) UnityEditorInternal.IL2CPPBuilder.RunIl2CppWithArguments (System.Collections.Generic.List1[T] arguments, System.Action1[T] setupStartInfo) (at <bfe26bbc7be749c7bb22d52435e15888>:0) UnityEditorInternal.IL2CPPBuilder.RunCompileAndLink (System.String il2cppBuildCacheSource) (at <bfe26bbc7be749c7bb22d52435e15888>:0) UnityEditorInternal.IL2CPPUtils.RunCompileAndLink (System.String tempFolder, System.String stagingAreaData, UnityEditorInternal.IIl2CppPlatformProvider platformProvider, System.Action1[T] modifyOutputBeforeCompile, UnityEditor.RuntimeClassRegistry runtimeClassRegistry, System.String il2cppBuildCacheSource) (at :0)
UnityEditor.Android.PostProcessor.Tasks.RunIl2Cpp.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at :0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at :0)
UnityEditor.Android.PostProcessAndroidPlayer.PostProcess (UnityEditor.BuildTarget target, System.String stagingAreaData, System.String stagingArea, System.String playerPackage, System.String installPath, System.String companyName, System.String productName, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at :0)
UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at :0)
UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, System.String installPath, System.String companyName, System.String productName, System.Int32 width, System.Int32 height, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at :0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
`

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.