Attempting to do a "sway" effect

Hello, i’m trying to do a bounce effect when you move your mouse with an object

Just like this:

I have a spring module by Quenty that should help, but i can’t get the correct mouse delta.

Input.Delta only works when the camera is locked or moved by holding right click.

And i’m also not sure how to do it.

3 Likes

Delta describes the displacement between two vectors. You could tap into a RunService event and get the displacement of the mouse between two frames which would be your delta.

1 Like

So is it like this?

local rs = game:GetService("RunService")

local uis = game:GetService("UserInputService")

local pos = uis:GetMouseLocation()

local lastPosition = pos

local delta = nil

rs.RenderStepped:Connect(function()

local newPosition = uis:GetMouseLocation()

delta = newPosition - lastPosition

lastPosition = newPosition

end)
1 Like

Okay, if that’s somehow right, How would i make it bounce with a Spring module?

1 Like

Yep an additional idea is, instead of using mouse delta to use the delta in the change of position of the tower.

That is also a delta you could use.

For a bounce with spring module you can convert it to terms of angular velocity and displacement like here:

It’s the same concept as an fps viewmodel sway, and there’s multiple methods about it, you might like the one from fps framework 2 which is simpler.

2 Likes

What is the method “fps framework 2”?

1 Like

The post below the post

1 Like