Aligning RootPart with animation, without "jump"

Currently, I have a climbing animation where a player basically climbs to the top of a pipe, as seen below. To move the humanoidrootpart I currently set its CFrame to that of the UpperTorso after the animation finishes, but that seems to cause a visible “jump” at the end. Does anyone know a better solution? Cheers

Code:
RootPart.CFrame = UpperTorso.CFrame

1 Like

I’ll assume, in your character’s default pose, the HRP is positioned lower/away from the UpperTorso by a significant amount. I’ll also assume this is how the end frame of your animation looks, to which you would perhaps reposition the HRP to the centre location of the UpperTorso before stopping the animation.


Grey box shows the HRP in its original position

In that case, there are two things happening:

  1. The character interpolates (or smoothly move) back to the starting pose very quickly after the animation has been completed, which could explain the character floating forwardly for a split second and going back before resolving on the top of the wall.
  2. The UpperTorso’s and HRP’s positions are distant enough even in pose mode. This would perhaps explain the slight fall.

You can’t directly align the HRP to the UpperTorso (also true in R6 in some cases) because their CFrames are too distant to each other, which can cause the jumping effect. There’s a bit of a difference in the height in this illustration of my character:



The Y-axis position of my UpperTorso in this scenario is actually higher than my HRP’s


You can, however, do a bit more mathematics with the RootRigAttachment pair of the LowerTorso and HRP. In this method, you will have to get the offset between the HRP and the LowerTorso’s RootRigAttachment.WorldCFrames, then apply to the character model’s pivot, like so:

-- Assume that all the listed items are present.
local model = script.Parent -- Place of the Model with the HumanoidRootPart and LowerTorso as direct children.

local rootPartRootAttachment = model.HumanoidRootPart.RootRigAttachment
local lowerTorsoRootAttachment = model.LowerTorso.RootRigAttachment

-- CFrame:ToObjectSpace() creates another CFrame that tells the relative offset according to the origin CFrame. A:ToObjectSpace(B) is not the same as B:ToObjectSpace(A)!
local offset = rootPartRootAttachment.WorldCFrame:ToObjectSpace(
	lowerTorsoRootAttachment.WorldCFrame
)

-- I prefer to adjust the model itself. Now, move the model's pivot to itself + the offset:
model:PivotTo(model:GetPivot() * offset) -- Order matters.

In terms of the animation interpolating, the quickest solution on the top of my head (not an expert with animations, so feel free to correct me) is: if you have an event keyframe around the end that tells the game to move the HRP on the wall, try making the easing style of the relevant frame(s) Constant instead.

1 Like

Thank you for the thorough answer

1 Like

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