How should you position the humanoid root part after an animation?

  1. What do you want to achieve? I want to move the player to where the animation finishes right when it ends

  2. What is the issue? You can clearly see the frame where I had to teleport the root towards the final location, but it’s just painful to watch and gives you a headache after some time.

This is the issue :

  1. What solutions have you tried so far? I tried to use Animation.Stopped:Wait(), but that obviously doesn’t work properly

So I’ve been working on a system to move around with animations around the office of my game, problem is ; the humanoid root part doesn’t move with the animation so I have to move it after said animation with a tween, any ideas of how I could perform a less obvious movement after the animation?

This is the code I’m using currently for the animation, all other animations are just this but with different IDs :

if input.KeyCode == Enum.KeyCode.A and workspace.GameValues.PositionValue.Value == "Computer" then
		
		actionval.Value = true
		
		local walkAnim = Instance.new("Animation")
		walkAnim.AnimationId = "rbxassetid://animationID"

		local walkAnimTrack = workspace[player.Name].Humanoid.Animator:LoadAnimation(walkAnim)
		walkAnimTrack:Play()
		walkAnimTrack.Stopped:Wait()
		actionval.Value = false
		local pos = Vector3.new(-197.6, 3.1, 106)
		local orientation = Vector3.new(-0, 90, -0)
		game.ReplicatedStorage.MoveCharacter:FireServer("LeftHall",pos, orientation) 
end

This is my code for the remote event that tweens the humanoid root part :

local tweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(
	0.01,	
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.InOut,	
	0,
	false,
	0
)


game.ReplicatedStorage.MoveCharacter.OnServerEvent:Connect(function(player, ptc ,position, orientation)
	workspace.GameValues.PositionValue.Value = ptc
	
	local changes = {
		Position = position,
		Orientation = orientation
	}
	
	local tween = tweenService:Create(workspace[player.Name].HumanoidRootPart, tweenInfo, changes)
	tween:Play()
end)

What you can do to make it seemless is when the animation finishes, set the camera CFrame to the desired position, then do your character movement and then you can lock the camera back to the character, if that makes sense?

Also do you need to tween the character? It might work as intended if you simply CFrame the character to the dummy also.

3 Likes

Thank you so much! I used a mixture of both of your ideas and although the code is a tiny bit messier now as I have to rely on animation timings (.Stopped:Wait()) would do it too late) it’s almost seemless now.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.