Character Movement Broken Down in "Movement States"

First of all, I want to make it very clear that I am a beginner with little experience with Roblox Lua. Lua itself is not an issue for me, that I’ve gotten through already.

As a beginner, I’m still on the “starting low” process, of course. So being a huge fan of movement in games, I’m hoping that a movement system is simple enough for me to figure out and script “by myself” (me, the DevForum and API). Specially if I plan on “improving” Roblox default movement.

What I was thinking about is breaking movement down in multiple states (walking, sprinting, jumping, and so on), and having a better way of handling the player speed, as simply using the Humanoid’s WalkSpeed value doesn’t seem that practical for a game in which, for example, the player can get faster and faster from practice/training/progression, while each state will have a different speed, such as the player being faster while sprinting when compared to walking.

Few examples of how certain games deal with movement;

  • "Mighty Omega"

Players have two different states for running; jogging, that conserves Stamina at the cost of speed, and sprinting, consuming more Stamina while also running at their max speed. Players can also increase their overall running speed in-game via training.

  • "Grand Piece Online"

Players can walk and run at fixed speed. While blocking, their movement is slowed down, and with certain “powers”, they can Fly at speeds much different than their “grounded movement”.

  • "Zenkai Origins"

Players have multiple states of movement; walking, sprinting, floating, flying, and “boost flying”. Each one at very different speeds, those which can be increase from stat points and using “temporary power boosts”.

  • "Parkour"

By far the Roblox game with the most advanced movement. Not only the player’s movement speed includes momentum, slowly building up speed, but there are also a few “states” in which the player has different move speeds, such as crawling, running, wall-running, wall-climbing, and so on. I do recommend trying this game out, as its movement is way more complex than I can explain.
I highly doubt this game’s movement is built strictly using Humanoid’s WalkSpeed.

Of course, I’m not sure if any of those games use a “state based system”, but you can break their movement down using one, and that’s the goal I’m trying to achieve in my system; breaking movement down in different states so it becomes easier to manage when the character’s speed can be increased or decreased in certain situations. Note that I’m merely making a project, not a whole game, that would be too much for a beginner like me.

So, how difficult would it be to achieve that? What would I need to learn to reach that goal? Is it possible to “improve” how Roblox handles movement, making it more malleable?

A reminder that I’m not asking for a code, I can’t learn that way. Using a code to give me an insight is alright, though, as it would help me visualize what I’m supposed to do and what I’m supposed to search for to get a better understanding of that planned system.

TL;DR - How difficult would it be to divide character movement into multiple states, such as walking, running, flying and jumping? Is it possible to make a new movement system instead of using Roblox’s Humanoid WalkSpeed, or making a more malleable system from it? Which methods would be most appropriate for doing so?

Thank you for the read, and forgive the wall of text.

i suppose you could use variables

run_number = 0
--shift to add 1 to run number and key to make it 2
run_number.changed.function:connect()
if run number = 1 then
--run script
else if run number = 2 then
--block script
else if run number = 0 then
--walk script
end

this is just an example

1 Like

Have BoolValue instances represent individual movement states, when one is enabled, disable the rest.

2 Likes

Sounds way simpler than I figured, its kind of scary even. So, knowing that, I presume it’d be two-way communication, then?

With my really limited scripting experience and knowledge, I’d say I’ll need two LocalScripts, one for reading the player input, and another one for handling the player’s animations (which I want to include to further challenge myself). A ModuleScript that will manage the movement states, and a Script that will actually change the player’s movement states.

Player executes input via LocalScript and sends that information towards the ModuleScript (that manages the states), the ModuleScript triggers an event for the Script to change the player’s current movement state, then when the player’s state is changed, then the Script communicates with the LocalScript that handles animations in order to swap the current movement animation (according to the movement state).

Is that it, have I not even gotten close to the right method or did I just overcomplicate?

2 Likes