LinearVelocity applied force direction changes when tool that has a handle gets equipped

I am trying to apply velocity to character’s HumanoidRootPart.CFrame.lookVector, however, when I equip a tool that has a handle and add LinearVelocity, it no longer gets applied to lookVector, but somehow slightly sideways instead.

Perhaps I am doing something wrong, please let me know. This also continues happening even if I unequip the tool with handle, which really confuses me.

Tool, without a handle, that applies velocity to RootPart’s lookVector, notice how player keeps moving the same direction:

Tool with a handle, that applies velocity to RootPart’s lookVector, notice how player moving direction slightly changes:

This is the code:

local function createVelocity(part, velocitySize, duration)
	local Attachment = Instance.new("Attachment", part)
	local LV = Instance.new("LinearVelocity", Attachment) 
	LV.MaxForce = 2000 * part.AssemblyMass
	LV.VectorVelocity = part.CFrame.lookVector * velocitySize
	LV.Attachment0 = Attachment 
	game.Debris:AddItem(Attachment, duration)
end

tool.Activated:Connect(function()
	local character = tool.Parent
	local rootPart = character.HumanoidRootPart
	createVelocity(rootPart, 20, 0.25)
end)

Also the project
Mover_Issue2.rbxl (67.9 KB)

Try changing the linear velocity attachment world position to the handle.CenterOfMass position.

Thanks for the reply. I tried it, but it made no difference. Here’s how I modified “createVelocity” function based on your suggestion:

local function createVelocity(part, velocitySize, duration)
	local Attachment = Instance.new("Attachment", part)
	local HandleTool = part.Parent:FindFirstChild("HandleTool")
	if HandleTool then
		Attachment.Position = HandleTool.Handle.CenterOfMass
	end
	local LV = Instance.new("LinearVelocity", Attachment) 
	LV.MaxForce = 2000 * part.AssemblyMass
	LV.VectorVelocity = part.CFrame.lookVector * velocitySize
	LV.Attachment0 = Attachment 
	game.Debris:AddItem(Attachment, duration)
end

Let me know if this is not what you had in mind.

EDIT: I read again what you said and tried one more thing. Since the Handle.CenterOfMass is Vector3.new(0, 0, 0) and Vector3.new(0, 0, 0) in world space is Character’s HumanoidRootPart position, I tried to set attachment position to HumanoidRootPart position:

local function createVelocity(part, velocitySize, duration)
	local Attachment = Instance.new("Attachment", part)
	local HandleTool = part.Parent:FindFirstChild("HandleTool")
	if HandleTool then
		Attachment.Position = part.Position
	end
	local LV = Instance.new("LinearVelocity", Attachment) 
	LV.MaxForce = 2000 * part.AssemblyMass
	LV.VectorVelocity = part.CFrame.lookVector * velocitySize
	LV.Attachment0 = Attachment 
	game.Debris:AddItem(Attachment, duration)
end

However it didn’t work that well. Result:

Apologies, I meant

Attachment.WorldPosition,

if it doesn’t work it’s because the linear velocity only applies the force at the attachment point in vector mode.

You can try using PlaneVelocity or LineVelocity mode which does not follow this behavior:

1 Like

Thanks! This works! If anyone wonders, this is how I modified the function:

local function createVelocity(part, velocitySize, duration)
	local Attachment = Instance.new("Attachment", part)
	Attachment.WorldPosition = part.AssemblyCenterOfMass
	local LV = Instance.new("LinearVelocity", Attachment) 
	LV.MaxForce = 2000 * part.AssemblyMass
	LV.VectorVelocity = part.CFrame.lookVector * velocitySize
	LV.Attachment0 = Attachment 
	game.Debris:AddItem(Attachment, duration)
end

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