Assemblylinearvelocity inconsistent

I am working on a game that relies on physics so the first that I thought to do was use assemblylinearvelocity it worked with no issues at all until I decided to add jump pads

jump pads are super inconsistent which makes it harder to get past those stages for new players


Here is the local script placed in startercharacterscripts

script.Parent.Humanoid.Touched:Connect(function(hit)
	local HumanoidRootPart = script.Parent.HumanoidRootPart
	if hit.Name == "Jump" and Db == false then
		local Velocity = HumanoidRootPart.AssemblyLinearVelocity
		HumanoidRootPart.AssemblyLinearVelocity = hit.CFrame.UpVector * 200 + Velocity
		Db = true
		task.wait(0.1)
		Db = false
	end
end)

I tried many things to get this working
-increasing assemblylinearvelocity using jumppad upvector
-setting it to a new value
-getting direction(cam.CFrame.LookVector) where player ragdolled then applying velocity using that and jumppad upvector
-getting hrp assemblylinearvelocity and adding that with jumppad upvector

Also, the way the player ragdolls himself is using assemblylinearvelocity too so that could be the issue but I don’t know if there are good alternatives that would work out with me

Thanks for any help

2 Likes

just use :ApplyImpulse() instead

2 Likes


Doesn’t seem to work quite well

Idk works just fine imo
Just give it more power etc: Vec+(Vector3.yAxis*100)

I could give it more power but it will sometimes do less than it should which is what I want to avoid

Well becouse it is affected by other forces most likely.
You can make limbs massless and give it just tiny more power than expected.

Still inconsistent idk what else I should do

Are you using a server script?

No, I am using local script i said that in the post btw

Does anyone know alternative or a fix?

Thank you for being respectful. I appreciate your compassion. I read past that part when I was reading your post

I would try to help you with it if you share the file with me or with everyone

It’s a full game so I won’t be sharing the whole game I will just share the part related to ragdoll and jump pad tell me if anything isn’t clear in the script

local UIS = game:GetService("UserInputService")
local RagdollModule = require(game:GetService("ReplicatedStorage"):WaitForChild("Ragdoll"))
local CAS = game:GetService("ContextActionService")

local Cam = game.Workspace.CurrentCamera
local Db = false
local Ragdolled = false

local function UnRagdollOnStop(HumanoidRootPart)

	local LastPosition = HumanoidRootPart.Position
	
	while task.wait(0.5) do
		if not HumanoidRootPart then break end
		
		if Ragdolled == false then
			break
		end
		
		local NewPosition = HumanoidRootPart.Position
		
		local Distance = (NewPosition - LastPosition).Magnitude
		
		if Distance <= 1 then
			RagdollModule.UnRagdoll(script.Parent)
			Ragdolled = false
			break
		else
			LastPosition = NewPosition
		end

	end
end

local function Ragdoll(name,state,object)
	
	if state == Enum.UserInputState.Begin then
		local HumanoidRootPart = script.Parent.HumanoidRootPart
		local Humanoid = script.Parent.Humanoid
		
		if Ragdolled == false then
			RagdollModule.Ragdoll(script.Parent)
			HumanoidRootPart:ApplyImpulse(Cam.CFrame.LookVector * 650)
			Ragdolled = true
		end
		UnRagdollOnStop(HumanoidRootPart)
	end
end

CAS:BindAction("Ragdoll",Ragdoll,true,Enum.KeyCode.E,Enum.KeyCode.ButtonX)

local RagdollButton = CAS:GetButton("Ragdoll")

if RagdollButton then
	RagdollButton.Size = UDim2.new(0.25, 0,0.3, 0)
end

CAS:SetTitle("Ragdoll","Ragdoll")
CAS:SetPosition("Ragdoll",UDim2.fromScale(0.15,0.3))

script.Parent.Humanoid.Touched:Connect(function(hit)
	local HumanoidRootPart = script.Parent.HumanoidRootPart
	if hit.Name == "Jump" and Db == false then
		local Velocity = HumanoidRootPart.AssemblyLinearVelocity
		HumanoidRootPart:ApplyImpulse(hit.CFrame.UpVector * 900)
		Db = true
		task.wait(0.1)
		Db = false
	elseif hit.Name == "Boost" and Db == false then
		HumanoidRootPart.AssemblyLinearVelocity = hit.CFrame.LookVector * 100
		Db = true
		task.wait(0.1)
		Db = false
	end
end)

1 Like

i used this for my obby game (on a local script aswell):

local hrp = char.HumanoidRootPart

local attachment = hrp:FindFirstChild("JumpPadAttachment") or Instance.new("Attachment")
attachment.Name = "JumpPadAttachment"
attachment.Parent = hrp

-- Create the LinearVelocity force
local lv = Instance.new("LinearVelocity")
lv.Name = "JumpPadVelocity"
lv.Attachment0 = attachment
v.VelocityConstraintMode = Enum.VelocityConstraintMode.Vector
lv.RelativeTo = Enum.ActuatorRelativeTo.Attachment0
lv.VectorVelocity = VectorDirection * Force_Multiplier
lv.MaxForce = math.huge
lv.Parent = hrp

task.delay(0.1, function()
	if lv then lv:Destroy() end
end)

This works exactly how I want it to be but made my character fly across the map xd. lv is kinda a bit strong even with destroying it faster

but I am wondering if lv solves the issue then when will I need to use assemblylinearvelocity?

The only time i recommend using assemblylinearvelocity for physics is something like this (you can use this for moving platforms in your game btw):

game:GetService("RunService").RenderStepped:Connect(function(dt)
	for _, platformData in pairs(movingPlatforms) do
		local platform = platformData.part
		local lastPos = platformData.lastPos

		if lastPos then
			platform.AssemblyLinearVelocity = (platform.Position - lastPos) / dt
		else
			platform.AssemblyLinearVelocity = Vector3.zero
		end

		platformData.lastPos = platform.Position
	end
end)

and also, if you want less force on your LV, then do something like

lv.VectorVelocity = VectorDirection * Force_Multiplier

Set VectorDirection to the current force you are applying
Then you can set Force_Multiplier to something like 0.5 for it to be a lot weaker (just so you know the force value doesnt work linearly, it has more of an exponential curve from what ive seen)

1 Like

Thanks for your help I appreciate it

1 Like

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