Modified Spring Module

Hello! I just wanted to start this post by saying that this is my first time posting on the DevForum so my apologies if this is in the incorrect category.

  • Why was this even made?

I’ve been developing a first-person shooter the past few days and the biggest issue I had to come up against was FPS unlockers. It took me 2 days to find the fix and I don’t want anyone else to go through that so here, have an edited version of x_o’s spring module that works independently of the client’s FPS.

Usage wise the module is the same as the original.

  • You can create a new spring using the Spring:Create(Mass, Force, Damping, Speed) function. In case you don’t pass any values, the module will autofill them for you using defaults.
    An example from my game: local rot_Spring = SpringModule:Create(5, 40, 10, 3)

  • You can “Shove” a spring using the Spring:Shove(Force) function, where Force can either be a CFrame or Vector3.
    An example from my game: rot_Spring:Shove(Vector3.new(-ad_Y, -ad_X, math.clamp(-ad_X, rot_NegMax, rot_PosMax)))

  • To get the position from a spring you have to update it using the Spring:Update(Delta) function.
    An example from my game being: rot_Vector = rot_Spring:Update(Delta)

  • In the event of you needing to change the mass of a spring, for example, you can do that by doing Spring.Mass = Desired_Mass

You can get it here on my public release repo.

13 Likes

Could you show demonstrations of what it can do? It’s API? Examples?

4 Likes

local springmodule = require(game.ReplicatedStorage:WaitForChild(“Spring”))
local recoilspring = springmodule.Create()
local camera = game.Workspace.Camera
local run = game:GetService(“RunService”)
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()

run.RenderStepped:Connect(function(dt)
local updatedrecoilspring = recoilspring:Update(dt)
camera.CFrame *= CFrame.Angles(math.rad(updatedrecoilspring.x),0,0)
> – for more angles you replace the 0 with updatedrecoilspring.y or z and then edit the shove
end)

mouse.Button1Down:Connect(function()
recoilspring:Shove(Vector3.new(4,0,0))
end)

simple code but hope this helps.

W man. I was gonna do it but you saved me some time

2 Likes