You mean, in the Pose that the character has at the end of your animation? (Like “with arms wide open”) ?
Or you mean, your animation is moving the LowerTorso part to a different position (like walking away from the center point of the animation) ?
I guess its the second one.
I would try to do it by using a KeyframeMarker inside your animation. That event can be readed while the animation is running.
The idea would be, fire the KeyframeMarker when the animation is about to finish, one keyframe before it ends maybe or at the very end, and you listen that event in the script, changing the HRP position of the player to the LowerTorso position readed when the KeyframeMarker was fired (using a slight offset of HRP vs LowerTorso positions)
You would use the Animation:GetMarkerReachedSignal("KeyframeMarkerName) to listen the KeyEvent in your script GetMarkerReachedSignal()
A slight problem you might encounter with the method above is the relativity animations have to the HumanoidRootPart. This is dependent on your animations, both ways can be used
Let’s say you have a walking animation, when the animation is finished you position the HumanoidRootPart to the LowerTorso’s position. You will see that the character gets pushed forward because it’s returning to the original position (Humanoid Root Part), since it’s not automatically snapped.
A solution I found was to, instead use the actual Keyframes in the animation to determine when to teleport the HumanoidRootPart. As you can see below, the last Keyframe that does anything is named EndKeyFrame which indicated when to start teleporting.
The Keyframe after is the additional Keyframe, which is set to the original position of the LowerTorso which will help us snap in place.
Once added, you need to connect a function to read when a Keyframe is reached. After that you just need to position the Character or HumanoidRootPart.
local LoadedTrack = -- Loaded animation track
local connection = LoadedTrack.KeyframeReached:Connect(function(keyName)
if keyName == "EndKeyFrame" then
Character:MoveTo(Character.LowerTorso.Position + Vector3.new(0, Character.LowerTorso.Size.Y * 2, 0))
-- Adjust position based on LowerTorso size, smooths out snap
end
end)
LoadedTrack.Ended:Connect(function()
connection:Disconnect() -- Cleanup connection
end)
Everything seems to be working, but one thing: When it ends, it slides my avatar back, and then it teleports it, is there a way to not make it slide back and then teleport, but make it teleport earlier, so that doesnt happen?
The best possible result requires that your EndKeyFrame be as close as possible to the last Keyframe in your animation. If it’s still sliding in that case, you may need to play around with the other method using AnimationTrack.TimePosition and AnimationTrack.Length.
The harsh reality is that animations simply aren’t meant to be used this way. You can try and find some sort of bandaid fix, such as teleporting the player a frame before the animation ends, but you should just use physics to move the HumanoidRootPart.
Using some sort of physic constraint, and not the animation, to apply velocity to the HumanoidRootPart would be the most ideal and proper solution here.
I see your connecting remote events inside of CharacterAdded. This is a terrible idea, as everytime the player respawns, it will be connected again. It also doesn’t check if the player calling the remote. You need to either move it out of PlayerAdded, or check if the caller is the player you want, and you’ll have to disconnect old connections when unused.
I think a good approach would be, not changing the position of the character during the animation, the animation should keep the player in the origin position, and perform the movement of the character using a MoverConstraint or BodyMover, as you stated.
The animation of @DanielosthebestYTAlt , seems like a dash, then the dash should be done by scripts, and the animation should not change the LowerTorso position
Yup, I think you should edit the animation, and do not change the position of the player, just the sliding tackle animation at the origin point of the character. Then by scripts you should apply the “dash”, in that way the animation plays, the character actually does the dash in server.
Its a soccer game, would be better to handle that sliding tackle without depending on where is the character during the animation, otherwise, it will complicate other systems (like stealing the ball when theres is contact with it during the sliding)
I would love to, but I never made a dash system before, I can think on a couple of approaches on how to achieve it, but I dont have that experience, so any of those ideas would be the best one and I dont know which one is.