How would I use the force that a SpringConstraint calculates?

  1. What do you want to achieve?
    I want to make a custom spring out of a VectorForce. And I am trying to use the SpringConstraint as a “property object” that it just there for me to control the spring properties (it doesn’t have an Attachment0 or Attachment1 set)

  2. What is the issue?
    My issue is that when I use the calculated force, my car just sits there without hovering. Which is not what is suppossed to happen.

  3. What solutions have you tried so far?
    I have tried chaning up the equation, but got no luck.

This is what the calculation looks like: (I copied it from the SpringConstraint page here)

local Spring: SpringConstraint = self.Spring

local Attachment0: Attachment = self.Wheel.Thruster
local Attachment1: Attachment = self.Wheel.Attachment

-- Result is just a RaycastResult
local CurrentLength = if (Result) then Result.Distance else Spring.FreeLength

-- Calculations

local FreeLength = Spring.FreeLength
if (Spring.LimitsEnabled) then
	CurrentLength = math.clamp(CurrentLength, Spring.MinLength, Spring.MaxLength)
	FreeLength = math.clamp(FreeLength, Spring.MinLength, Spring.MaxLength)
end
local SpringLength = (CurrentLength - FreeLength)

local Axis = (Attachment0.WorldPosition - Attachment1.WorldPosition).Unit
local EffectiveVelocity = (Attachment0.Parent.AssemblyLinearVelocity - Attachment1.Parent.AssemblyLinearVelocity)
local ForceExternal = Vector3.new(0, -workspace.Gravity, 0)
local Force = -Spring.Stiffness * SpringLength - Spring.Damping * Axis:Dot(EffectiveVelocity) + Axis:Dot(ForceExternal)

Force = math.clamp(Force, -Spring.MaxForce, Spring.MaxForce)

This is how I set the force of the VectorForce:

self.VectorForce.Force = Vector3.new(0,Force,0)

Video showing the problem:


The VectorForces (there is one for every wheel) seem to be only 20k Force, which is not enough to lift the car. And the VectorForces are located in the RootPart of the car.

Any help is appreciated! :+1:

You havent tried adjusting stiffness and the dampening?

Also have you added a reaction force?

My character controller uses vectorforces springs which work, you can look there for a possible reference.