Camera shakes violently when tweening the HumanoidRootPart

I’ve tried tweening the HRP to go along with the animation, so it moves somewhere. The problem is that when I try to do a high dive, the camera violently shakes, as if the HumanoidRootPart (seeing as the camera target is the HRP) is colliding against something and simulating unwanted physics. Maybe it’s something in the script? I dunno. I’ve checked the character hierarchy and have found nothing, and I have nothing else welded to my character that might cause those problems.

game:GetService("UserInputService").InputBegan:Connect(function(input, gameprocess)
	if (not gameprocess) then
		if backpack.IsTackled.Value == true then return end
		if switch.Value == "Goalkeeper" then
			if react == true then return end
			if debounce == true then return end
			if count == 1 then return end
			if holdingBall.Value == true then return end
			if input.KeyCode == Enum.KeyCode.Q then
				debounce = true
				react = true
				sprintDisabled.Value = true
				humanoid.WalkSpeed = 0
				humanoid.JumpPower = 0
				local animtrack = humanoid:LoadAnimation(anims.ZDive)
				animtrack.Priority = Enum.AnimationPriority.Action
				animtrack:Play()
				animtrack:AdjustSpeed(2)
				local TweenService = game:GetService("TweenService")
				local Info = TweenInfo.new(1.05, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
				local Tween = TweenService:Create(HRP, Info, {
					CFrame = HRP.CFrame * CFrame.new(-10, 5, 0)
				})
				Tween:Play()
				wait(1)
				react = false
				humanoid.WalkSpeed = 14
				humanoid.JumpPower = 50
				sprintDisabled.Value = false
				wait(0.4)
				debounce = false
			end
		end
	end
end)

Try anchoring the HRP before playing the tween, and then unanchor it afterwards.

Physics still works even during tweening, causing the jittery camera, so anchoring it is the best way to prevent that.

2 Likes

I thought that the HRP was already anchored. It shows up as anchored if I spawn a rig.

Alright, I’ve tried that solution. However, a new problem occurs. After the tween finishes, I can move normally, but if I jump and try to move in another direction, it’ll go somewhere else.

By that, do you mean the character seems to teleport upon jumping?

1 Like

No, it behaves strangely. If I for example try to jump and press W, the character feels like it’s being pushed in another direction and doesn’t do what it’s instructed to do.

1 Like

Does that new problem occur if you were to run the game without my prior solution?

(The most likely culprit would be a heavy part or force attached to the character, but I’m ruling that out for now since you’ve stated that you’ve checked the character for welds or oddities during runtime.)

a tween wont work on the hrp if its anchored…

It seems you’re trying to do a goalkeeper dive in soccer? I don’t recommend using TweenService as it’s meant for visual effects more than gameplay actions.
BodyVelocity should work fine here for the dive motion.

2 Likes

Will BodyVelocity keep it in the air? Thing is, I’m trying to implement a high dive that will stay in the air for a set amount of time.

Yes it would. That’s the whole point of tweening.

1 Like

Then why havent you found a solution yet?

It will if you make the Y axis of MaxForce big enough, such as math.huge.
I recommend setting the MaxForce to Vector3.new(1, 1, 1) * math.huge.

1 Like

As @guidable stated, you’re better off using BodyMovers for something like this. You can also create an animation so it feels me real

3 Likes

There’s one thing I’m confused about though, how do you make the velocity relative to the character? If it’s facing forward, back, or left, I always want it to move to the left of the character, for example. How do I do that? I’ve tried using lookvector * the vector3, but to no avail.

Do you mean that you want it to change the direction mid-air based on the character?

No, I mean like, since the velocity is a set value, how do I make it so it moves left relative to the character’s orientation, instead of the world space?

Why can’t you use -CFrame.RightVector * DivePower?

local Mover = Instance.new("BodyVelocity")
				Mover.MaxForce = Vector3.new(1, 1, 1) * math.huge
				Mover.Velocity = HRP.CFrame.RightVector * Vector3.new(-10, 0, 0)
				Mover.Parent = HRP
				Debris:AddItem(Mover, 1)

This is what I currently have at the moment. RightVector doesn’t seem to work either.

You should not be using a vector to apply power, just a number. RightVector isn’t in object space, rather it’s a unit vector that describes a direction.

1 Like