Hey DevForum, I need your opinion on what the best way to accomplish the following, especially since I am not great with ROBLOX specific elements like animations.
I have an animation:
Currently, as you might be able to see, the player goes back to the starting position after the animation. I dont want this to happen tho.
I need the player to stay (and be instantly allowed to keep moving) at the furthest most point in the animation. (Smoothly.)
Maybe when the animation is about to end, you could grab the value of the Transform property of a Motor6D in the UpperTorso. Then, when the animation ends, you could set the UpperTorso’s CFrame to-
UpperTorso.CFrame = saved_transform
Just an idea, not really sure if this’ll work as desired.
Use BodyMovers for actual position movement, don’t use the animation for that. The animation should only handle player limb movement, and the part that should actually move the player forward should be the BodyMover
It’s better if you use TweenService or BodyMovers, as @rek_kie mentioned, instead of changing their position in the animation. You’d want to update the animation so that they dash forward in place, rather than actually moving, then use TweenService to change their position:
local TweenService = game:GetService("TweenService")
local offset = 5 -- player moves 5 studs in front of their position; this should really be the offset you apply in the original animation
local tw = TweenService:Create(playerHRP, TweenInfo.new(time, easingstyle, easingdirection), {CFrame = playerHRP.CFrame * CFrame.new(0, 0, -offset)} -- tween the player forward by a specified offset
tw:Play()
Of course, you’d want to use raycasting in this so that the player isn’t able to clip through walls:
local ray = Ray.new(playerHRP.Position, playerHRP.CFrame.LookVector * offset)
local _, pos = workspace:FindPartOnRay(ray, playerCharacter)
local TweenService = game:GetService("TweenService")
local tw = TweenService:Create(playerHRP, TweenInfo.new(time, easingstyle, easingdirection), {CFrame = CFrame.new(pos) * CFrame.new(0, 0, 1)} -- move to the hit position, but 1 stud behind
tw:Play()