Rope constraint flings character on jump

Description of the problem

I was making a tool for a small game I’m working on, and it’s basically a toilet plunger that you can throw that uses a rope constraint. It works exactly how I want it to, until the player actually throws the plunger. When the player throws the plunger and jumps, the player gets flung for some reason.

Here’s a video that shows you what I’m talking about:


Code

There are two rope constraints. One is from the rope mesh that goes to the handle of the tool, and the other is from the handle of the tool to the plunger’s handle. When the player throws the plunger, the rope constraint that goes from the tool’s handle to the plunger’s handle gets disabled and is invisible. Then, the rope constraint that goes from the rope mesh to the handle is changed to go to from the rope mesh to the handle of the plunger. The length of this rope is also changed to 30 from its default length of 5.

-- called when the tool is being charged
function chargePlunger()
	local swingAnimation = animations["Swing"]
	swingAnimation:Play(SWING_CHARGE_TIME, 1, 0)
	chargeStartTick = tick()
	swung = false
end


-- called when the plunger is thrown
function throwPlunger()
	ropeConstraint2.Visible = false
	ropeConstraint2.Enabled = false
	ropeConstraint.Attachment1 = plungerHandleAttachment
	ropeConstraint.Length = THROW_ROPE_DISTANCE
end


-- called when the plunger is attempted to be swung
function attemptToSwingPlunger()
	if swinging then
		return
	end
	if swung then
		return
	end
	local swingAnimation = animations["Swing"]
	if tick() - chargeStartTick >= SWING_CHARGE_TIME then
		print("Swinging")
		swinging = true
		swingAnimation:AdjustSpeed(1)
		local connection = swingAnimation:GetMarkerReachedSignal("ThrowPlunger"):Connect(function()
			throwPlunger()
		end)
		swingAnimation.Stopped:Wait()
		connection:Disconnect()
		swinging = false
		swung = true
	else
		print("Animation Stopped")
		swingAnimation:Stop()
	end
end

Conclusion & Extra Details

Is there any way to fix this behavior? I just don’t want the player to be flung whenever the player jumps after the plunger is thrown. I can’t seem to figure out why this even happens. The plunger is not massless, but that shouldn’t affect the character in any way. Has anyone had this problem before?

Try setting the massless poperty of the plunger to true, this might fix it.

1 Like

This didn’t work. In fact, it actually made it 10x worse. The player now gets flung for even having the plunger in their hand.

Thats probably because Collisions on the Plunger are enabled.

I’d recommend either disabling the collisions on the tool completely or giving the parts within the tool and the player’s character into seperate collion groups using PhysicsService.

This shouldn’t be a problem, since in the original video at the top nothing happened when the plunger was in the player’s hand. This only happens when the plunger gets thrown, and at that point, there is no collision happening with the player and the plunger. There is only collision happening with the plunger and the environment, but that’s intended.

I don’t understand why the rope constraint being attached to the rope mesh and the plunger is making the player get flung when they jump. There isn’t any sort of collision happening between the player and the plunger, so it doesn’t make sense.

Bumping this topic back up because I’m still looking for a fix. Upon further investigation I noticed this only happens when the rope length gets increased. With a small rope length, this does not happen. I’m going to assume it’s a bug, but I’m not entirely sure this is a bug.

1 Like

Usually this bug occurs if an unanchored object with CanCollide enabled is parented to the player. Is the plunger parented to the player?

If yes, try parenting it to something else and see if it fixes

2 Likes