Not sure if this is exactly something that fits under Scripting Support, but there isn’t really a Physics Support or Studio Support topic so I think this fits the most.
Currently, I have an animation play when someone jumps after sliding, and that animation offsets the torso forward quite a bit for cinematic effect. The problem is that the player can spin their character around (either with shift lock or just wasd), and even after the animation concludes, the character’s center of mass is thrown off.
Code:
local slideJumpCD = false
hum.StateChanged:Connect(function(oldState,newState)
if newState == Enum.HumanoidStateType.Jumping then
if sliding then
if not slideJumpCD and slideSpeed then
hrp:ApplyImpulse((hrp.CFrame.LookVector + Vector3.new(0, 0.15, 0)) * (450 + slideSpeed/3))
local at = animator:LoadAnimation(script.SlideHop)
at.Priority = Enum.AnimationPriority.Action2
at:Play(.1, 1, 2)
coroutine.wrap(function()
task.wait(1)
slideJumpCD = false
end)()
end
stopSlide("Jump")
end
end
end
Hmm. I don’t think this would be a problem with the animation. Try looking through all of your code to see if you can find any issues. If you are unsure about a section of code and suspect the possibility of it being the problem, you can come back here. However, if you find absolutely nothing, I suggest creating a post in Bug Reports.
I’m not really sure what I should be looking for. None of my code touches anything relating to the character’s mass, and I saw there was a common problem with the same result when the character is anchored during an animation, but none of my code does that. The only things I could think of is maybe layering animations with different priorities or stopping animations with a facetime of 0, but I could find anything online saying that those have known mass bugs. I’ll give it a few days and if I don’t find a solution I’ll post a bug report.
I think I see the problem here. When you jump right after sliding, your animation doesn’t complete. Since jumping takes the new priority of the animation, I think which ever animation offsets the torso kind of just leaves it there until the animation runs again. Since the animation is offsetting the torso it causes the characters center of mass to be thrown off. I’d say the best course of action as of now is to test if this is the case, try fully going through with the sliding animation, and then moving. See if that throws it off or not.
Just to clarify, are you saying the sliding animation doesn’t complete or the default Roblox jumping animation doesn’t complete? I’ll test what you said tomorrow morning, and just for extra info, in the stopSlide function called at the bottom it cancels the sliding animation.
That’s just for something else, basically every time it stops the slide animation it tracks what caused it to stop. I just use it for something relating to the cooldown
Oh okay, honestly I feel like as long as you’re just taking the current animation track and calling AnimationTrack:Stop() it should work… But you can try doing the test I suggested tomorrow.
I’m not sure what it really means, but isolating the slide-jump animation from the slide (just binding it to a key and jumping when I press it) doesn’t cause any issues, and simply removing the animation from the original code I had written both work without issue, so I think you may have been right about it being some animation overlap issue. I’m just gonna keep poking at stuff, but if you have any ideas let me know.
I came to the solution just by messing around. By simply destroying the LinearVelocity for the sliding immediately before playing the animation instead of immediately after, the center of mass remained accurate.