I’m not sure what you mean by delta time locking the spring. Could you clarify what you mean? I believe I resolved a similar issue recently, so make sure you’re using the updated version of the Spring Module.
would it be possible to use this and make car suspension? the roblox one is not that good and its really weird
Update 9/19/2022
-
Added
SpringObject:SetGoal()
function that sets the external force of the SpringObject such that the limit of the offset of the spring as time approaches infinity is equal to the given number. This function is also the same asSpringObject:SetExternalForce(goal * SpringObject.Constant)
-
Added
SpringObject:Print()
function that prints the SpringObject to the output in a nice formatted string -
Added
tostring(SpringObject)
functionality, which returns the SpringObject converted into a formatted string. This string is what is output inSpringObject:Print()
Could I use this for UI? or is the purely for parts and camera work
This module can be used for anything that needs a spring. All it does is create an object with a number that, when visualized, behaves like a spring would. So you can use this module for anything!
That’s great to hear! I will be using this in my game.
how do i use it for gun recoil??
Best spring module ever!
I love this spring module, i am literally in love with it. It has a bunch of useful functions, i dont have to call the update function every single frame in a rendersteps, and i dont have to calculate the speed by yourself in the rendersteps. I am just in love with it, and there is no words in this world to describe how good it is.
You did such a good work bhristt!
The only thing that i dont like, is that there is no SetOffset() function. So i could set the offset instantly to whatever number i want. Im pretty sure it would be actually useful for people if you would add it.
In my case i needed to reset the spring every time i was equipping a new weapon because weapon’s cframe was being controlled by the spring.
But yeah, i just love it, you made my life a lot easier with this, thank you so much!
Thanks so much for your kind words, I appreciate it greatly! :')
Also, I added a sort of ‘SetOffset’ function. For this spring module, the function is Spring:SetGoal
. You can get the current goal of the spring by using the property Spring.Goal
. There’s more information on this in the github repository; hope this helps!
Oh, no i meant the instant SetOffset function. That instantly sets the offset to whatever number you need.
The function would be something like this:
function SpringFunctions:SetOffset(offset: number)
local self: Eq.Spring & SpringObject = self;
-- set properties and restart spring
self.InitialOffset = offset;
self.InitialVelocity = 0;
self.ExternalForce = 0;
self:Reset();
self:SetGoal(self.Offset);
end
Hello, is it possible to use this module for car suspension?
I think no. I guess you can use SpringConstraint
.
This is great! Is there any way I can use this to create a camera system similar to the one seen in Doors? I’m currently working on a game similar to Doors and I really want to replicate their camera system.
Did I understand any of the math equations he was talking about?
No.
Will I use the module anyway knowing I probably won’t know how to use it?
ABSOLUTELY!
best module ever!!!
Update 11/9/2023 (SpringModule V2.0)
-
Reworked damping: Instead of
dampingForce = dampingConstant
, it now works asdampingForce = dampingConstant*mass
. Damping force should now change with mass. -
New constructor: Added new
Spring.fromFrequency()
constructor. This takes in a frequency instead of a spring constant, and calculates the spring constant of the spring to match the given frequency. Frequency is the time it takes for the spring to complete a full oscillation. -
SpringObject:SetFrequency: Added
SpringObject:SetFrequency()
function. This function takes in a frequency and sets the spring constant of the SpringObject to match the given frequency. -
SpringObject:SnapToCriticalDamping: Added
SpringObject:SnapToCriticalDamping()
function. Calling this function will snap the spring to critical damping by changing the damping. Critical damping is the point where the Spring turns from exponential motion to oscillating motion. -
SpringObject:SetOffset: Added
SpringObject:SetOffset
function. Calling this function will set the offset of the SpringObject to the given offset. If zeroVelocity argument is true, this function sets the velocity of the SpringObject to 0. -
SpringObject:SetVelocity: Added
SpringObject:SetVelocity
function. Calling this function sets the velocity of the SpringObject to the given velocity.
For new documentation, please refer to the github documentation!
Get the new version of the module here!
Don’t hesitate to ask questions about this update, I’ll try my best to answer all questions! :V
Hi,
Do you have an example .rbxl of a working spring?
Thanks
Man, im looking at the desmos graph, AND I LOVE WHAT I SEE!!
thank you so much for working on this!
you’re the best
Can this spring module be used for UI?
Yes, a Spring object calculates a single number. Because of this, the Spring is by design 1D. To make it 2D, just create and use two springs and change the properties of each spring according to their respective X/Y directions.