Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to accurately measure player footsteps? (Unanswered)

Asked by 4 years ago
Edited 4 years ago

Hello fellow scripters, I hope you are having a great day! While scripting my 2D Platformer game, I have encountered an issue with detecting player steps. At the present time, I am using a touched event to detect player footsteps. The problem is that this is not very accurate and that it causes issues later hand. The normal solution would be using "GetMarkerReachedSignal", but I want players to be able to use the animations that they have bought in the game rather than a custom animation that is used while playing. I have scavenged Roblox Wiki Pages and multiple Dev Forum pages for days, but I wasn't able to find a concept for this.

I don't need the whole code but just a concept or a Roblox wiki site that could somewhat help me. If you could help in any way or form, I would really appreciate it. Thank you!

0
hmm im not exactly sure what you want but if you want to count how many steps a player has taken you could probably track how many times the roblox default walking animation has been played and update a variable each time it is played. Code1400 75 — 4y
0
Yeah, I just want to count the steps a player has taken. I see that your solution is similar to IdealistDeveloper.The problem is that the default animation includes the player stepping many times. However this is still a great idea and I greatly appreciate your response. :) SprinkledFruit101 135 — 4y
0
I just want to say that this question is still unanswered. If anybody could help me in any form or way I would appreciate it. :D SprinkledFruit101 135 — 4y

1 answer

Log in to vote
2
Answered by 4 years ago
Edited 4 years ago

Hi Sprinkled,

If they are using even their own animation, odds are that the animation is probably looped/not looped. Now, you can check every time the animation comes to an end, or repeats a loop. The most accurate way to count footsteps would probably be to check when the whole animation is repeated/finished playing.

You can check if the animation is looped by using animationTrack.looped.

Go here to find out more about that.

Once you know whether it's looped or not, you can detect when the animation reaches an end/repeats again.

If it's looped

If the animation is looped, you can use the animationTrack.DidLoop event.

Go here to find out more about that.

If not looped

If the animation is not looped, you can use the animationTrack.Stopped event.

Go here to find out more about that.

Conclusion

Keep in mind that these are animationTracks that have these functions, not the animation object itself. So, this will be an object returned from :LoadAnimation. Anyways, hope I helped and have a wonderful day/night.

Check out more info about animationTracks here.

Thanks,

Best regards,

IdealistDeveloper

0
Yes, so this technque would work but I realize that the player steps multiple times in a single animation and I am not sure if it is the same amount of steps for each unique animation. So it wouldnt work if you were to add the steps value by one each time the animation finishes. Thank you for your response and I hope you have a great day or night as well. :) SprinkledFruit101 135 — 4y
0
If you need me to elaborate on what I'm saying I'm glad to do so. Thank you for the help! SprinkledFruit101 135 — 4y
0
im pretty sure the roblox default animations are available to the public so you could put them into the animation editor and see how many steps are in the animation Code1400 75 — 4y
0
i am not sure of this as it may not be the same for each and every animation and I am not able to find a version of the animations where you can open them in animation editor. SprinkledFruit101 135 — 4y
View all comments (5 more)
0
I'll try my best to find it regardless, thank you! SprinkledFruit101 135 — 4y
0
I am not able to find it... SprinkledFruit101 135 — 4y
0
If you're going to leave it up to whatever animation the player may have equipped, then I don't think there's any other way to count the amount of steps. We have to assume some level of basic 'normalness.' Like, the animation won't be more than 2 seconds long or so. If so, it doesn't matter if the animation looks like it has 2 steps in those 2 seconds or 1 step in those 2 seconds, because either IdealistDeveloper 234 — 4y
0
either way it is still 2 seconds. Rather than counting steps you can count the amount of seconds that were spent walking and just make that an integer value (remove any values after the decimal by using math.floor) and then just say that's the amount of steps. IdealistDeveloper 234 — 4y
0
The reason this is a better way is because you can take around 1 step in 1 second, so it is more reasonable, fair, and much more realistic. Not to mention that you don't give control to the client and Roblox itself anymore, but rather to your own system you've implemented. IdealistDeveloper 234 — 4y
Ad

Answer this question