stormcai
(stormcai)
May 15, 2020, 6:37pm
#1
Hey guys ive been trying to get my viewmodel to sway correctly buy it doesnt work.
This is what im trying to achieve:
I’m putting a place down below so you guys can see for yourselves. The problem is the spring is too stiff. No matter what i try i cant get the part to oscillate back and forth. Does anybody know how to fix this?
sway place.rbxl (19.3 KB)
So in the place i have a part that is supposed to act like the viewmodel. Test it out to see what you guys think.
Tom_atoes
(Tom_atoes)
May 15, 2020, 7:17pm
#2
Are you referring to the viewmodel moving up and down whilst the player is moving?
stormcai
(stormcai)
May 16, 2020, 12:46am
#3
Yes, that is exactly what i mean
Tom_atoes
(Tom_atoes)
May 16, 2020, 9:17am
#4
This is a separate thing. You can use springs for this if you want, but it isn’t required.
You need to set up a function that returns a cframe offset that you can apply to your view model.
The best way to do this is with a sine wave and tick().
function getBobbing(xMultiplier, yMultiplier, Modifier)
local bobTick = tick()
local offsetX = math.sin(bobTick * xMultiplier) * Modifier
local offsetY = math.abs(math.sin(bobTick * yMultiplier) * Modifier
return CFrame.new(offsetX, offsetY, 0)
end
getBobbing(5, 7, 0.5)
This will need some modification to get it to work in the way you want, but the code I provided will work for a basic bobbing system.