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
colbert2677
(ImagineerColbert)
September 25, 2021, 3:29am
#2
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
dthecoolest
(dthecoolest)
September 28, 2021, 10:57pm
#5
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.
Here made something, cool to spring up your FPS view model:
It’s a local script which uses Quenty’s spring module to add a spring effect to the otherwise static view model.
Before spring:
After Spring:
Code, insert into your starterCharacter scripts as a local script and test it out. Values for the spring will need adjusting of course.
–Edit: Here’s a better working version with the dampening actually working, messed up the previous CFrame calculation. Still have no …
3 Likes
What is the method “fps framework 2”?
1 Like