AssemblyLinearVelocity is wrong

local RunService = game:GetService("RunService")

local Part = workspace:WaitForChild("Part")

local function Heartbeat()
	Part.AssemblyLinearVelocity = Vector3.new(0, workspace.Gravity, 0)
	return
end

RunService.Heartbeat:Connect(Heartbeat)

result

explain please

1 Like

workspace.Gravity is a magnitude value without the direction. By default it’s positive 196.2 studs/seconds ^2.
image

Just like how gravity in real life is a acceleration magnitude of 9.81 ms^-1

Since gravity is downwards to translate it into an acceleration vector it will be:

local acceleration = Vector3.new(0, -1, 0) * workspace.Gravity

Also notice this is an acceleration vector, not velocity.

So what are you intending to do using acceleration as velocity in the original code?

1 Like

using velocity i want the normal force to resist the gravitational force

1 Like

Normally for this kind of problem you will use a body mover like BodyForce to let Roblox engine apply the antigravity force with the code example there.

Maybe you should explain more what are further intending to do.

Are you just curious at how the engine applies the antigravity force and what to manipulate AssemblyLinearVelocity the same way?

If so maybe :ApplyImpulse() is the better method to apply force. But I’m having the same issues where it goes up as well. I’m thinking doing is RunService might not be in sync with the Roblox physics engine which runs at 240 Hz y’know.

Seems like a lot of unneeded work.

2 Likes

I need to know this to translate it to vectorforce.

1 Like

Oh, then you can just do something similar with BodyForce and get the gravitational force.

F = mg
F = Force
g = Workspace.Gravity
m = mass, use part:GetMass()

local vectorForce = script.Parent

local part = script.Parent.Parent


local attachment = Instance.new("Attachment")
attachment.Parent = part
vectorForce.ApplyAtCenterOfMass = true
vectorForce.Attachment0 = attachment

vectorForce.Force = Vector3.new(0,Workspace.Gravity*part:GetMass(),0)
2 Likes

ok then, how would I create a spring effect using vector force? when every other tutorial uses velocity? which is what im trying to do. I am not a moron

1 Like

Creating a spring effect requires a dampening force(or else the oscillations become infinite). Velocity is just a vector measurement.

1 Like

I know, it is very easy to create a spring using velocity and integrating it. But using vector force to create a spring is more difficult. Which is why I am asking for help.

I don’t think using vector force is harder? You’d just have to take into consideration the mass , acceleration and gravity.

Why is this not workign

local RunService = game:GetService("RunService")

local Part = workspace:WaitForChild("Part")

local VectorForce = Part:WaitForChild("VectorForce")

local Weight = Part.AssemblyMass * workspace.Gravity

local Y = 0
local k = 1
local c = 1

local function Heartbeat()
	local x = Y - Part.Position.Y
	local Fs = k * x
	local v = Part.CFrame:VectorToObjectSpace(Part.AssemblyLinearVelocity)
	local Ff = -c * v
	VectorForce.Force = Vector3.new(0, Weight + (Fs + Ff.Y), 0)
	return
end

RunService.Heartbeat:Connect(Heartbeat)

if it is so much easier?

Where did you get the formula from? This doesn’t look like the one to get the actual dampening force.

google: damping force formula that is the formula

How is adding the force going to help? The dampening force doesn’t take into consideration the mass?