Directional Movement System

  1. What do you want to achieve? Keep it simple and clear!

I want to create a directional movement system and make it so I can switch my animations (Right, left, forward, backwards) while moving.

  1. What is the issue? Include screenshots / videos if possible!

I edited Roblox’s “Animate” script and there animations play when events fire.
Humanoid.Running event fires again only when you stop holding any key that moves your character . That’s why it doesn’t switch animations when I keep holding at least one button (W, A, S, D)

Here’re the functions that are responsible for directional movement:

function CalculateMovement()
	local DirectionOfMovement = HRP.CFrame:VectorToObjectSpace( HRP.AssemblyLinearVelocity )
	local walkspeed = Humanoid.WalkSpeed

	local Forward = math.abs( math.clamp( DirectionOfMovement.Z / walkspeed, -1, 0 ) )
	local Backwards = math.abs( math.clamp( DirectionOfMovement.Z / walkspeed, 0, 1 ) )
	local Right = math.abs( math.clamp( DirectionOfMovement.X / walkspeed, 0, 1 ) )
	local Left = math.abs( math.clamp( DirectionOfMovement.X / walkspeed, -1, 0 ) )
	
	local speed = DirectionOfMovement.Magnitude  
	local anim
	if speed > .75 then
		local scale = 16.0
		if Forward > 0.5 then
			anim = "Forward"
		elseif Forward < 0.5 and Backwards < 0.5 then
			if Left >= 0.5  then
				anim = "Left"
			elseif Right >= 0.5 then
				anim = "Right"
			end
		elseif Backwards >= 0.5 then
			anim = "Backwards"
		end
	end
	return anim, speed
end

function onRunning()
	local direction, speed = CalculateMovement()

	local scale = 16
	if direction == "Forward" then
		playAnimation("walkforward", 0.2, Humanoid)
		setAnimationSpeed(speed / scale)
	elseif direction == "Left" then
		playAnimation("walkleft", 0.2, Humanoid)
		setAnimationSpeed(speed / scale)
	elseif direction == "Right" then
		playAnimation("walkright", 0.2, Humanoid)
		setAnimationSpeed(speed / scale)
	elseif direction == "Backwards" then
		playAnimation("walkbackwards", 0.2, Humanoid)
		setAnimationSpeed(speed / scale)
	else
		playAnimation("idle", 0.2, Humanoid)
		pose = "Standing"
	end
end

Humanoid.Running:Connect(onRunning)
  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I tried to use RunService. It works but it breaks other animations that I need, like jumping, since they are called by events like Humanoid.Jumping.

Here is my Animate script:
Animate.rbxm (11.6 KB)

Would appreciate any help!

4 Likes

you mean smth similar to this?



well it’s known as one of popular system mostly Roblox Developers need but none of them were actually good cuz:

  1. Inverse Kinematics are buggy
  2. produceral doesn’t work on crouch, run and mostly systems
  3. animations are not linked and could break on mobile support

if u are finding this system without using animations that also works NOT locally then u can download these models (1 lean 1 Cframe Movement 1 Massless Movement) and test it in ur game:
Lean = allow your torso to lean right and left
Lean Torso Movement.rbxm (1.7 KB)
D Lerp Movement = allow your torso, legs, arms to lerp orientation using Cframe
DLerpMovement.rbxm (3.1 KB)
Massless Movement = allow your character to become complete massless (except head)
massless character.rbxm (790 Bytes)
to create Backpedaling, you need to create a script that when you move backwards ur walk animation adjustspeed turn into -1 or just add another animation and set priority into Idle

Only use Massless Movement when your game is a horror game!

D Lerp Support Arm Rotation (if it’s not comfortable then set up Arm rotate to 0)

goodluck learning from these, all 3 in StarterCharacterScripts (especially DLerp and Massless)

3 Likes

I’d actually prefer movement systems that use animations.
Concerning your videos, are these animations or procedural animations?
And how would massless movement help me?

to answer your question:

those are procedural that moves/rotate body part’s Cframes

Massless is when your body parts have no mass, it will make your body parts work like Evade and other r6 games, but i don’t force you to use it and neither the others

devdump has a really good video on directional movement that uses animation but its only for r6 so im not sure if you can somehow convert it to r15 https://www.youtube.com/watch?v=aP_VzBxrPOA here is the vid on it tho

1 Like

I was just about to say the samething

Devdump’s tutorial is really good and explains it well.

it already has R15 in toolbox but i don’t know how to find it ._.

sorry if i didnt respond but here is the model https://create.roblox.com/marketplace/asset/15005531513/Directional-Walk-Movement-System%3Fkeyword=&pageNumber=&pagePosition=

ah thx i was looking for this just to see how it works with only 4 directions