How can I make a running system like TSB?

I’m currently making a fighting game, and I’d like to add a sprinting system that makes you walk faster and changes your walk animation while you’re running forwards. However, there are things that I haven’t figured out so far:

  • How would I make it detect that you’re running forwards on mobile or console?
    On PC, I could simply check if the player is holding the “W” key and go from there, however, on mobile, I have no idea how i could check if the player is going forwards.
  • How would I make it change the walking animation without it overriding the existing animations (Punching, dashing, etc)

I’ve tried to find solutions for these, but I couldn’t find anything useful. Any help is appreciated.

Please use google before asking questions.

This is not what I was looking for. It does not have anything that I specified, and it also has a stamina bar (which i do not want)

Then google it again till you find your result.

Also just use gemini or chat gpt for asking questions. People say they suck but they don’t. They are good ONLY for beginners like you.

1 Like

None of these are what I’m looking for either… I kind of feel like you didn’t really read my post. I also said in the post itself that I already searched for it, but I couldn’t find it.

I did read through your post. And if nothing matched your context then the simplest way to explain it would be:

  • Make a sprinting animations and set it’s priority to something above your walking animations but ensure it’s less than that of your other animations (Punching, dashing, etc)
  • Detect key presses using ContextActionService for sprinting which adds a button for mobile automatically.
  • To check if player goes forward you use some CFrame maths like so:
local moveDirection = Humanoid.MoveDirection
local relativeDireection = HumanoidRootPart.CFrame:VectorToObjectSpace(moveDirection)
local forwardDirection = relativeDirection.Z

If the forward direction is less than zero then the player is moving forwards.

  • To play the animation just load the animation to the humanoids animator and play it when you sprint and stop it when you… don’t sprint.

Strongest Battlegounds doesnt really do anything special for their running animations

Use humanoid state changed and change the animation to running

Simply set the running animation to a higher priority than your punching and dashing in the animation editor before publishing

Humanoid State Changed AFAIK doesn’t change for walking and such. If you are idle/walking, it stays at “Running”.

You mean lower than that of OP’s punching and dashing.

yeah i misread mb

I didnt know that I never used but I know it exists. Shouldn’t there be a humanoid.Walking to make this work?

the example script seems to have worked, i would just have to find a way to fix it not detecting the player moving forwards if the camera if the player is rotating rapidly with shiftlock and if the player is walking diagonally (A + W or D + W)

No, AFAIK (as far as I know) I don’t think there is one. Maybe I’m wrong.

For the diagonal moment you can just see if the X-component of the relativeDirection variable is not zero.

If this solved it then please mark the post as a solution to let others know.

After some tweaks, I got it working. Thanks for the help, I’ll mark your reply as the solution.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.