top of page

Step Counter

Making the step counter was easy in the sense of that there are many various sources of documentations and blog posts of people receiving help in these kinds of problems. Our game went through so many changes that in the end it became a type of activity app with a Tamagotchi experience tied to it. The activity part was necessary in our opinion because we wanted to set our game apart from the many apps that was similar to the game we were making.

After making the tilt function that used Unity’s own functions library that gives access to a smartphone’s many functionalities I had a solid foundation to further implement a more advanced application for our game. I started by declaring two variables of type float called hiLim and loLim that would represent the accuracy of when a step is taking place. I also declared two variables of the type float called currentAcceleration(currAcc) and averageAcceleration(avgAcc) that was meant to calculate the distance of acceleration between each other. The value of this was monitored in a function called StepDetector which was called upon in another function called FixedUpdate that updates each frame. In the StepDetector function I assigned the variables currAcc and avgAcc an interpolated result of the last known value of each variable, the length of the current acceleration or magnitude and the current time with a type of noise filer to reduce frequencies above a set value. After that is initialized I created a float called delta that was assigned the value of the difference between the two variables. A statement that checks if variable of type bool, which can only be true or false, that represents each step taken is then activated. This statement should be false if this function is recently activated and should then lead in to another statement that looks at the value of the delta variable and compares it to the hiLim variable I mentioned earlier. This Boolean statement is then assigned on and off depending on how far it travels when the player takes a step.

It was hard to calibrate the values to detect when a step was taken, either it was too sensitive or it was not sensitive enough. After some calibrating, it could register almost all steps a person took at any given time. Not perfect but for the GGC show it did what it needed to do.


Utvalda inlägg
Titta in snart igen
När inlägg har publicerats hittar du dem här.
Senaste inlägg
Arkiv
Sök efter taggar
Inga taggar än.
Följ oss
  • Facebook Basic Square
  • Twitter Basic Square
  • Google+ Basic Square
bottom of page