Character movement as a step at a time

After having to temporarily take a break from learning scripting thanks to college completely occupying all of my time, I’m finally going back to teaching myself. Just when I was finally learning! Ugh!

This time, my plan is to make a boxing game that PLAYS like boxing, since so far I haven’t seen a proper boxing game in this platform. Fortunately, I did box for a few months, which will for sure help me out when mixing gameplay elements with how boxing works. I plan on actually pushing through and trying to, at least, finish this project, being my first project to ever come to an end.

So, for the first few steps, I plan on working on building a new character movement system to replace Roblox’ built-in system, that will be put to action whenever the player is actively boxing (be it in a match, sparring, shadow boxing and so on). For each of the directional keys (WASD), when pressed (not held down — pressed), the character will take a single step towards the desired direction (in the example I linked, that would be two steps forward, two steps back). Of course, you’ll only move in steps while boxing, not while training or fooling around.

However, I have pretty much no scripting experience, and with that lack of experience, I don’t know how to start making this system. Any advice and/or hint is appreciated. All I need is to be pushed to the right direction.
P.S: I’ll first get the major features functional before working on any animations.

4 Likes

You could start with 4 stepping animations. 1 for the forward direction, 1 for the back direction, etc.

Then you could use UserInputService to detect if the player pressed any of the WASD keys. You could achieve this by using the InputBegan & InputEnded event. Here is a sample snippet of how it would look like:

local UIS = game:GetService("UserInputService")
local currentTick = 0
local lastTick = currentTick
local acceptableTime = 0.15 -- in seconds

UIS.InputBegan:Connect(function(input, ae)
	if ae then return end
	if input.KeyCode == Enum.KeyCode.W then
		currentTick = tick()
		lastTick = currentTick
	end
end)

UIS.InputEnded:Connect(function(input, ae)
	if input.KeyCode == Enum.KeyCode.W then
		currentTick = tick()
		if currentTick - lastTick <= acceptableTime then
			print("pressed")
            --- code that runs when player pressed and not holds the W key
		end
		lastTick = currentTick
	end
end)

Then you could play the loaded animations inside the if-statement. You could adjust the code above as it is just a reference for the actual code that you will be creating. Also, don’t hesitate to ask a question/s if you have one. Goodluck on the project!

4 Likes

Thank you, though what I wish to accomplish is building a new movement system exclusive to when the player is actively boxing (as in a bout, sparring, shadow boxing or working the bags), one that works in singular steps instead of just moving in short sections. My plan is to first get the stepping system functional before working on animations.
After re-reading my post, I realize that I wasn’t as clear as I thought I was. I’ll edit it out.

Made a little visual for what I have in mind in Blender, just for the sake of clarity. Didn’t animate anything to reflect how it should look like after I get the system done, before implementing a proper step animation.

2 Likes

A few days passed and I haven’t gotten this figured out. I did find out about Mover Constraints, though, which so far seem like the solution for what I have in mind. Perhaps I could use VectorForce and time it with tick() so that it works as a short dash?
Though my ignorant self has no idea on how to deal with collision issues, but I’ll just have to figure it out.

Along with that, since I plan on making a character progression with stats and trainings, I guess I should first work on said stats, since some could affect footwork.