Animation trying to bring the character back to his original position ruins the smoothness

  1. *What do you want to achieve?

I am trying to make a combat system, I made a grab and throw move, the user throws the person hit in the hitbox forward.

  1. *What is the issue?

The animation tries to bring back the target character to the start of the animation.

  1. *What solutions have you tried so far?

I tried to update the CFrame of the rootpart of the target putting the position of the torso, it works but for a few frames the game tries to pull the character into his starting position

Here is a video of what i mean
robloxapp-20240820-2222488.wmv (387.8 KB)

2 Likes

And here is the code without too much detail

abilitiesInfo["Grab and throw InputBegan"] = function(plr)
	local char = plr.Character
	local humanoid = char.Humanoid
	local target = returnHitbox(char) --we get the target with an hitbox, it works
	if target == nil then return end
	abilitiesInfo.DisableCollisions(char,target) --we disable the collision, it works
	local weld = Instance.new("WeldConstraint")
	weld.Part0 = char.HumanoidRootPart
	weld.Parent = char
	target.HumanoidRootPart.CFrame = char.HumanoidRootPart.CFrame
	weld.Part1 = target.HumanoidRootPart
	
	local userAnim = humanoid.Animator:LoadAnimation(script.anims["Super Strength"]["Grab and Throw"].char)
	local targetAnim = target.Humanoid.Animator:LoadAnimation(script.anims["Super Strength"]["Grab and Throw"].target)
	
	userAnim:Play()
	targetAnim:Play() --i load and start the animations, they work
	local pos
	userAnim:GetMarkerReachedSignal("fast1"):Connect(function()
		target.Humanoid.Health -= 1 --give a bit of damage, works
	end)
	userAnim:GetMarkerReachedSignal("pain"):Connect(function()
		target.Humanoid.Health -= 2 --give a bit of damage, works
	end)
	userAnim:GetMarkerReachedSignal("Throw"):Connect(function()
		target.Humanoid.Health -= 2
			
	end)
	userAnim:GetMarkerReachedSignal("hitGround"):Connect(function()
		target.Humanoid.Health -= 13 --give a bit of damage, works
		pos = target.Torso.CFrame	--we set the pos as the position of the torso
	end)
	
	userAnim:GetMarkerReachedSignal("CFrame"):Connect(function()
		if weld then
			weld:Destroy() --we destroy the weld
			weld = nil
		end
		pos = target.Torso.CFrame --we set pos as the position of the torso
	end)
	userAnim:GetMarkerReachedSignal("end"):Connect(function()
		abilitiesInfo.EnableCollisions(char,target) --we enable the collisions, it works
		target.HumanoidRootPart.CFrame = pos --we move the humanoidrootpart to the pos
		
	end)
	
end
1 Like