Roll animation for movement issue

You can write your topic however you want, but you need to answer these questions:

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

Basically, when u press z you do a roll and move forward a bit. (I did this with an animation.)

  1. What is the issue? Include enough details if possible!

-Issue 1
When the animation of the roll is finished u teleport back to the starting point, even though u move forward in the animation!
-Issue 2
When u do the animation, u can go straight through parts while doing the animation. CanCollide for the body is off. (It’s actually just a visual that’s moving, the body is still at the starting point but u just don’t see it) The problem with this is that u can’t just teleport the body to the visual body that is doing the animation. Because then it’s possible to clip inside of parts.

  1. What solutions have you thought of so far?

I tried using a hitibox with touch events that checks if u can roll without clipping into something.
The problem is that the character moves very strangely when u turn while walking. It looks like it speeds up, even though I turned CanCollide OFF for the hitbox. It probably has to do with the weldconstraint that makes it not just fall on the ground. Everything I try doesn’t work and that’s why I need your help. I don’t know any way of avoiding clipping into parts.

Thank you for reading this and have a great day!

2 Likes

I think the issue stems from moving the player in the animation itself, which probably causes issue 1 and is probably related to issue 2 is well. Basically, keep the roll animation, but remove anything in the animation that moves you forward, you can make the player move during the animation via adding a BodyVelocity inside of them for a short time whilst the animation is playing

1 Like

It does move the player! But in only one direction, when u change the velocity. I want it to move to the direction that the player is facing, but I don’t know how to do that. (Sorry, I don’t really get how BodyVelocity works) And how do u speed up the speed of it moving?

Basically, do what I said, getting rid of the part where the person moves forward in the roll, keepign the roll itself.

Inorder to push the player when they roll, you again use BodyVelocitys, the velocity can be set by getting the LookVector of the player’s HumanoidRootPart’s CFrame. Here is some pseudocode to help you understand

local LocalPlayer = game.Players.LocalPlayer
local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
Local RootPart = Character:WaitForChild("HumanoidRootPart")
local Animator = Humanoid:FindFirstChild("Animator")

local UIS = game:GetService("UserInputService")
local Debris = game:GetService("Debris")

local RollAnimation = Animator:LoadAnimation(script.Roll) --We'll pretend your roll animation is in the script

local canRoll = true

UIS.InputBegan:Connect(function(input, gameprocessed)
	if gameprocessed then return end --Is the player is typing for example, don't activate
	
	if input.KeyCode == Enum.KeyCode.Z then
		if not canRoll then return end
		
		canRoll = false
		local BodyVelocity = Instance.new("BodyVelocity")
		BodyVelocity.MaxForce = Vector3.new(10000,10000,10000) --I typically do 10000 for each, but as long as it's a high number it should work, you can even use math.huge if wanted
		BodyVelocity.Velocity = RootPart.CFrame.LookVector * 50 --Change 50 to a different value to make it move you further or less
		BodyVelocity.Parent = RootPart --Important!!
		RollAnimation:Play()
		
		Debris:AddItem(BodyVelocity,0.3) --Make the BodyVelocity go away after 0.3 seconds
		wait(RollAnimation.Length)
		canRoll = true
	end
end)

This should be a baseline of how you can make BodyVelocity work, what this code does is if you press z and you can roll, it’ll add a BodyVelocity to your HumanoidRootPart that’ll be responsible for moving you forward, and parents it to your RootPart so it’ll move you and play the animation, and once it ends, you can roll again

1 Like

Thank you so much for the help and even making an entire script!

1 Like

Anytime! I made the entire script since making part of it or nothing at all wouldn’t be a good way to help you understand how the process is done, I hope you didn’t just copy and paste the entire script and not take any learning from it! Because extracting the main information I wanted to give out for doing this would be the best way to know what to do and even know how to do it in the future! If you have anymore issues don’t be afraid to make another post!

1 Like

Do you also know how to move the player up with body velocity instead of forward?

Instead of using

RootPart.CFrame.LookVector

Just use

RootPart.CFrame.UpVector
1 Like