I’ve seen similar videos before and I couldn’t figure out how to make a character move in a static animation. I’ve already tried doing something like RootMotion and read a lot of topics, but I couldn’t find anything. By the way, I also tried simply moving the RootPart at the end of the animation, but it looks weird because the camera stays in place. And I tried moving the RootPart using Tween and Run services, but it’s impossible to control the RootPart while it’s moving forward.
local USER_INPUT_SERVICE = game:GetService("UserInputService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local CHARACTER = player.Character or player.CharacterAdded:Wait()
local HUMANOID = CHARACTER:FindFirstChildOfClass("Humanoid")
local ANIMATOR : Animator = HUMANOID:WaitForChild("Animator") or Instance.new("Animator",HUMANOID)
local HUMANOID_ROOT_PART : Part = CHARACTER:WaitForChild("HumanoidRootPart")
local TORSO = CHARACTER:WaitForChild("Torso")
local RUN_SERVICE = game:GetService("RunService")
local TweenService = game:GetService("TweenService")
local TEST_ANIMATION = script.TESTANIM
local TEST_TRACK = ANIMATOR:LoadAnimation(TEST_ANIMATION)
TEST_TRACK.Looped = false
USER_INPUT_SERVICE.InputBegan:Connect(function(input,gpe)
if gpe then return end
if input.KeyCode == Enum.KeyCode.E then
local function moveCharacterSmoothly(HRP, offset)
local goal = {CFrame = HRP.CFrame * CFrame.new(offset)}
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
local tween = TweenService:Create(HRP, tweenInfo, goal)
tween:Play()
end
moveCharacterSmoothly(HUMANOID_ROOT_PART, Vector3.new(0, 0, -10))
end
end)
it’s a bad example but that’s all I have right now.
I think those who have played The Strongest Battleground at least once understand what I mean.
I tried to use this but it works somehow buggy and throws me in different directions
USER_INPUT_SERVICE.InputBegan:Connect(function(input,gpe)
if gpe then return end
if input.KeyCode == Enum.KeyCode.E then
RUN_SERVICE.RenderStepped:Connect(function(dt)
local LookVector = HUMANOID_ROOT_PART.CFrame.LookVector
HUMANOID_ROOT_PART.CFrame = HUMANOID_ROOT_PART.CFrame * CFrame.new(Vector3.new(0,0,-0.1),LookVector)
end)
end
end)
I don’t know why but my character’s legs are falling into the ground.
local USER_INPUT_SERVICE = game:GetService("UserInputService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local CHARACTER = player.Character or player.CharacterAdded:Wait()
local HUMANOID = CHARACTER:FindFirstChildOfClass("Humanoid")
local ANIMATOR : Animator = HUMANOID:WaitForChild("Animator") or Instance.new("Animator",HUMANOID)
local HUMANOID_ROOT_PART : Part = CHARACTER:WaitForChild("HumanoidRootPart")
local TORSO = CHARACTER:WaitForChild("Torso")
local RUN_SERVICE = game:GetService("RunService")
local TweenService = game:GetService("TweenService")
local LinearVelocity = Instance.new("LinearVelocity")
LinearVelocity.Parent = HUMANOID_ROOT_PART
LinearVelocity.Attachment0 = Instance.new("Attachment", HUMANOID_ROOT_PART)
LinearVelocity.MaxForce = math.huge
local TEST_ANIMATION = script.TESTANIM
local TEST_TRACK = ANIMATOR:LoadAnimation(TEST_ANIMATION)
TEST_TRACK.Looped = false
USER_INPUT_SERVICE.InputBegan:Connect(function(input,gpe)
if gpe then return end
if input.KeyCode == Enum.KeyCode.E then
RUN_SERVICE.RenderStepped:Connect(function(dt)
local direction = HUMANOID_ROOT_PART.CFrame.LookVector * 100
LinearVelocity.VectorVelocity = direction
task.delay(5, function()
LinearVelocity.VectorVelocity = Vector3.zero
end)
end)
end
end)