VectorForce not having a speed cap + really slow acceleration

The title pretty much explains it.

I have a vectorForce and i want it to have a speed cap at around 20 studs per second. Just setting its velocity to V3.new(20,0,0) makes it accelerate PAINFULLY slow and it also doesn’t stop accelerating after.

Also another issue i found is that when i put my part in the air, the force is MUCH MUCH grater, but when i fall back to the ground the force becomes pretty slow - this could be due to friction but im not usre

The desired effect is - pretty fast acceleration - low max speed, thats pretty much it.

From what i’ve noticed the constraint doesn’t have a drag force.

Any help is appreciated, i am willing to work with math (aka use code for this).

as the docs of VectorForce say:

The VectorForce constraint applies constant force to an assembly.

The problem is VectorForce applies constant force without any built-in speed limiting, so it will just keep accelerating forever. You need to manually calculate the force based on your current speed.

local maxSpeed = 20

connection = RunService.Heartbeat:Connect(function()
    local currentVelocity = part.AssemblyLinearVelocity
    local currentSpeed = currentVelocity.Magnitude
    
    if currentSpeed < maxSpeed then
        local speedDifference = maxSpeed - currentSpeed
        local forceMultiplier = math.min(speedDifference / maxSpeed, 1)
        vectorForce.Force = Vector3.new(1, 0, 0) * (your acceleration, higher for faster, lower for slower) * part.Mass * forceMultiplier
    else
        vectorForce.Force = Vector3.new(0, 0, 0)
    end
end)

For your second issue, you can either reduce your part’s friction in CustomPhysicalProperties or multiply the force by like 1.2 when the part is touching the ground to compensate.

You should probably use LinearVelocity.

2 Likes

VectorForce is a force, not a velocity, like you want. Use a LinearVelocity and configure the max force (determines acceleration) be high and the vector velocity to be low

Yeah but the linear velocity doesnt act well on slopes, as most of the time it keeps a constant speed

Also this works really well, but i have a question, lets say i want to make it start going forwards after lets say 5 seconds from the game starting, it will work if after the hearbeat function i just say

task.wait(5)
maxSpeed = 20

Edit: It works, thanks a lot for the help!!!

I am marking it as a solution but for anyone who wants to help with constraint forces, feel free to reply to the topic, as i said, any help is appreciated

You can change the direction and limit how much force LinearVelocity applies, per-axis (vector), in a line, in a plane and what it’s relative to.

Yeah but that still doesnt solve the issue of slopes, using a vector force solves that issue

How does using a vector force solve it in a way LinearVelocity can’t?

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