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)
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.
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)
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
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.
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)