I’ve followed a few tutorials. I’ve researched the API, I’ve even asked ChatGPT to help me create one but all have failed.
Can someone please help guide me on how to set up a basic functioning Pedometer for Unity?
The program just needs to be able to count steps and display them in a text box please.
I genuinely need help, I have been struggling with this for weeks.
I am not going to do all of it for you, especially as you didnt cover what you tried, but
In your animations, put key frames for when a foot touches the floor, and fill in a method to call say pedometer, then, in a component have the pedometer method, and have it increment an integer each time its called and update the text
I do not have an animation. I’m trying to simply design a system that passively increases the step counter each time the phone itself detects when the user is moving.
Sorry the psychic network was down.
This is what I have so far having completely restarted.
As for what I have tried, I followed this tutorial:
But it did not work, and the counter never updated.
I bought and tried the following program from the asset store, but it broke my Gradle System which caused me to delete a lot of my work and restart.
I’ve read through the API but it doesn’t make sense to me. Usually I understand what the API means but here, I can’t get a grip on the functionality.
using
System;
using
TMPro;
using
UnityEngine;
using
UnityEngine.InputSystem;
public class
ProtoStepCounter : MonoBehaviour {
public
TMP_Text stepCountText;
StepCounter systemStepCounter;
void
Start () {
systemStepCounter =
new
StepCounter ();
systemStepCounter.MakeCurrent ();
// systemStepCounter.enabled = true;
}
void
Update () {
if
(systemStepCounter !=
null
) {
stepCountText.text = $"Current Steps are: {systemStepCounter.stepCounter.value}";
}
}
}