Trying to make Tilt Dodge with R15

  1. What do you want to achieve? Keep it simple and clear!
    I want my character to tilt in the direction they dodge using a single animation with an R15 Rig.

  2. What is the issue? Include screenshots / videos if possible!
    Currently the way I’m trying to make it work is by tweening the LowerTorso Root toward the direction I want the dodge to go, the problem is if the key for dodging is spammed (Q) it can offset the character’s orientation well after the dodge is complete.

https://gyazo.com/11f4f44de21fa35f24034ec964794c40

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have tried it with and without the tweens (BodyGyro), but the most effective method seems to be tweening unless there is another method I am missing.
elseif key == "q" then
		-- quickstep!
		local camData = {}
		camData.CFrame = Camera.CFrame
		camData.Focus = Camera.Focus
		
		local TweenService = game:GetService("TweenService")
		local tweenInfo = TweenInfo.new(
			0.2, -- Time
			Enum.EasingStyle.Linear, -- EasingStyle
			Enum.EasingDirection.Out, -- EasingDirection
			0, -- RepeatCount (when less than zero the tween will loop indefinitely)
			true, -- Reverses (tween will reverse once reaching it's goal)
			0 -- DelayTime
		)
		
		local original =  lTorso.Root.C0
		
		--local TweenCenter = TweenService:Create(lTorso.Root, tweenInfo, {C0 = CFrame.Angles(0, 0, 0)})
		
		local TweenLeft = TweenService:Create(lTorso.Root, tweenInfo, {C0 = original*CFrame.Angles(0, 0, 1)})
		local TweenRight = TweenService:Create(lTorso.Root, tweenInfo, {C0 = original*CFrame.Angles(0, 0, -1)})
		local TweenFront = TweenService:Create(lTorso.Root, tweenInfo, {C0 = original*CFrame.Angles(-1, 0, 0)})
		local TweenBack = TweenService:Create(lTorso.Root, tweenInfo, {C0 = original*CFrame.Angles(1, 0, 0)})
		
		local speedMod = Humanoid.WalkSpeed
		
		local moveDir = Vector3.new(0,0,0)
		
		if UIS:IsKeyDown(Enum.KeyCode.A) then
			moveDir = moveDir+Vector3.new(-1.5,0,0)
			TweenLeft:Play()
		end	
		if UIS:IsKeyDown(Enum.KeyCode.D) then
			moveDir = moveDir+Vector3.new(1.5,0,0)
			TweenRight:Play()
		end
		if UIS:IsKeyDown(Enum.KeyCode.W) then
			moveDir = moveDir+Vector3.new(0,0,-1.5)
			TweenFront:Play()
		end		
		if UIS:IsKeyDown(Enum.KeyCode.S) then
			moveDir = moveDir+Vector3.new(0,0,1.5)
			TweenBack:Play()
		end
		moveDir = (moveDir == Vector3.new() and Vector3.new(0,0,1.5) or moveDir)
		
		camData.moveDir = moveDir
		
		fcd = true
		local data = {key="q",state="down",camData=camData,speed=speedMod}
		local succ = movementRemote:FireServer(data)
		fcd = false
	end
	
end)

I believe in the video it was just an animation then the HumanoidRootPart was moved with a BodyVelocity.

Animator:LoadAnimation

1 Like

Yes, an animation plays in another script, but I want the character itself to tilt based on the direction they are dodging since it is one animation, I want to make it look dynamic.

In the local script I’m showing, I just want to rotate the Character based on the key they pressed to move but I can’t seem to figure out a safe way for that to happen because if the key is spammed it will continue to tilt the character in that direction, offsetting them from the normal orientation after the dodge is complete.

1 Like

I do not think I want to use Tweens anymore for this, I need something more fluid so I can correct the orientation immediately after the dodge is used.

1 Like

Ohhh, okay. I assume this is because you’re creating a new tween for the same property so it cancels the current tween?

I make a connection to Tween.Completed then set the Properties to their goal values to be certain that even if the tween is canceled before it finishes with the correct values.

(You can also just predetermine the goal, so like, instead of setting original in the callback function, it’s stored in a higher scope so it doesn’t reference the C0 value that gets changed by the tween.)

I don’t think changes to C0 and C1 replicate even with if the client has network ownership, right? That might be something to check.

If I can’t reference the C0 value to rotate the character, then how could I make the tween tilt them?
This idea does seem like it would work, but with the way I’ve been making tweens up to this point have been relatively the same.

I’ve looked for hours trying to find a solution to making a momentary tilt to a dodge with R15 and all I’ve ever seen was tilt walking that which meant the tween was always active. If I could see an example of how this works in code I’d greatly appreciate it.

It’s very abstract to me and I’d love to understand it! :smile:

Sure. You said that if the button is spammed the C0 drifts away from what it should be. I believe this is because the tween is canceled before it can complete.

Here is a code example where a connection to Tween.Completed is used to reset the values even if the tween is interrupted by a new tween:

elseif key == "q" then
		-- quickstep!
		local camData = {}
		camData.CFrame = Camera.CFrame
		camData.Focus = Camera.Focus
		
		local TweenService = game:GetService("TweenService")
		local tweenInfo = TweenInfo.new(
			0.2, -- Time
			Enum.EasingStyle.Linear, -- EasingStyle
			Enum.EasingDirection.Out, -- EasingDirection
			0, -- RepeatCount (when less than zero the tween will loop indefinitely)
			true, -- Reverses (tween will reverse once reaching it's goal)
			0 -- DelayTime
		)
		
		local original =  lTorso.Root.C0 -- initial value
		
		local speedMod = Humanoid.WalkSpeed
		
		local moveDir = Vector3.new(0,0,0)
		
		local tween


		if UIS:IsKeyDown(Enum.KeyCode.A) then
			moveDir = moveDir+Vector3.new(-1.5,0,0)
			tween = TweenService:Create(lTorso.Root, tweenInfo, {C0 = original*CFrame.Angles(0, 0, 1)})
		end	
		if UIS:IsKeyDown(Enum.KeyCode.D) then
			moveDir = moveDir+Vector3.new(1.5,0,0)
			tween = TweenService:Create(lTorso.Root, tweenInfo, {C0 = original*CFrame.Angles(0, 0, -1)})
		end
		if UIS:IsKeyDown(Enum.KeyCode.W) then
			moveDir = moveDir+Vector3.new(0,0,-1.5)
			tween = TweenService:Create(lTorso.Root, tweenInfo, {C0 = original*CFrame.Angles(-1, 0, 0)})
		end		
		if UIS:IsKeyDown(Enum.KeyCode.S) then
			moveDir = moveDir+Vector3.new(0,0,1.5)
			tween = TweenService:Create(lTorso.Root, tweenInfo, {C0 = original*CFrame.Angles(1, 0, 0)})
		end
		if tween then
			tween:Play()
			tween.Completed:Connect(function()
				lTorso.Root.C0 = original
				tween:Destroy()
			end)
		end
		

		moveDir = (moveDir == Vector3.new() and Vector3.new(0,0,1.5) or moveDir)
		
		camData.moveDir = moveDir
		
		fcd = true
		local data = {key="q",state="down",camData=camData,speed=speedMod}
		local succ = movementRemote:FireServer(data)
		fcd = false
	end
	
end)

Maybe test that code and see if it fixes the problem.

If that doesn’t work, you can probably always just create four different animations for each direction.

1 Like

It didn’t, but I understand it now, “original” doesn’t seem to hold the initial value for the torso’s orientation.
Even though when a tween is cancelled, it is considered completed.

It all leads back to needing to correct the orientation in a manual way, thank you for you help but I’ll keep trying other things.

1 Like