-
What do you want to achieve? I want to move the player to where the animation finishes right when it ends
-
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 :
- 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)