Grapple Hook Velocity

I’ve just followed Cookie Tech’s tutorial on YouTube on the Grapple Hook System.

A RopeConstraint didn’t work for me (It worked fine, it’s just not what I was looking for), So I modified it to work with a RodConstraint.

When you let go of your mouseclick, it will stop the grapple, but the player loses all of their speed. I’d like the player to retain velocity after letting go of the grapple. How can I do this?

Script Dropdown
local uis = game:GetService("UserInputService")

local player = game:GetService("Players").LocalPlayer
local humanoid = player.Character:WaitForChild("Humanoid")
local root = player.Character:WaitForChild("HumanoidRootPart")
local mouse = player:GetMouse()
local keybind = Enum.KeyCode.E
local keydown = false

local debounce = false

local range = 300
local speed = 500
local ropeVisible = true
local ropeThickness = 0.2
local ropeColor = BrickColor.DarkGray()

local targetTransparency = 0.5

function vector_dist(a, b)
	local diff = a - b
	local dist = diff.Magnitude
	
	dist = math.floor(dist/1+0.5) * 1
	return dist
end

function attach(method, parent)
	if method == "Create" then
		local attachment = Instance.new("Attachment")
		attachment.Parent = parent
	elseif method == "Destroy" then
		parent.Attachment:Destroy()
	end
end

uis.InputEnded:Connect(function(key)
	if key.KeyCode == keybind then
		keydown = false
	end
end)

uis.InputBegan:Connect(function(key)
	if key.KeyCode ~= keybind then return end
	keydown = true
	if not debounce then
		debounce = true
		local hitpos = mouse.Hit.Position
		local dist = vector_dist(hitpos, root.Position)
		if dist <= range then
			local grappletarget = Instance.new("Part")
			grappletarget.Anchored = true
			grappletarget.Parent = game:GetService("Workspace")
			grappletarget.Position = hitpos
			grappletarget.Transparency = targetTransparency
			grappletarget.Size = Vector3.new(1, 1, 1)
			
			humanoid:ChangeState(Enum.HumanoidStateType.Physics)
			
			attach("Create", grappletarget)
			attach("Create", root)
			local ropeConstraint = Instance.new("RodConstraint")
			ropeConstraint.Parent = grappletarget
			ropeConstraint.Attachment0 = grappletarget.Attachment
			ropeConstraint.Attachment1 = root.Attachment
			
			ropeConstraint.Color = ropeColor
			ropeConstraint.Visible = ropeVisible
			ropeConstraint.Thickness = ropeThickness
			
			ropeConstraint.Length = 2
			
			repeat wait() until not keydown
			
			attach("Destroy", grappletarget)
			attach("Destroy", root)
			
			grappletarget.RodConstraint:Destroy()
			grappletarget:Destroy()

			humanoid:ChangeState(Enum.HumanoidStateType.Running)
		end
		debounce = false
	end
end)
1 Like

Can you emphasise what you mean? (Examples will help)

1 Like

When you grapple, you’ll move towards the target part. When you stop the grapple (release mouseclick), you stop mid-air. Your velocity is reset. I can’t really explain this in any other way, because that’s exactly what’s happening. When you release the grapple, you lose your velocity.

I can get a video shortly.

I don’t have permissions to attach files, so I uploaded it to google drive:
Google Drive - problem.mp4

I’m pretty sure I can get around this if I make my own movement system, but I don’t wanna do anything unnecessary, so I’ll wait for a response. If I don’t get an answer by tomorrow I’ll just try that instead.

I see what you mean, this is quite a complex task so you may have to code your own movement system, I hope you find luck with that!

1 Like

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