I’m currently using headstackk’s method of tool animation and it works fine so far.
However, I had decided to try some alternative methods in simulating fps recoil and whatnot. In my case, I’m using springs.
But when using this method, my animation doesn’t work, with only the viewmodel’s arms moving when the gun should be moving too.
https://gyazo.com/8f7efade54bb3284d78f6f222ed3a49a
function module.new(Tool, Camera)
-- Not important
end
function module:Update(dt) -- Called every renderstep
self.dt = dt
local recoil = self.RecoilSpring:update(self.dt)
self.Camera.CFrame = self.Camera.CFrame * CFrame.Angles(recoil.x, recoil.y, recoil.z)
end
function module:VisualizeFiring(Fired) -- Called on input began/end
self.Firing = Fired
if self.Firing then
Animate:GetAnimation("10196909192", self.Viewmodel.Humanoid.Animator, true)
Animate:PlayAnimation()
else
Animate:StopAnimation()
end
local function Fire()
self.RecoilSpring:shove(Vector3.new(0.02,0,0) * self.dt * 60)
task.delay(0.15, function() -- Push back
self.RecoilSpring:shove(Vector3.new(-0.02,0,0) * self.dt * 60)
end)
task.wait(60/200) -- Rate of fire (RPM)
end
repeat
self.CanFire = true
Fire()
self.CanFire = false
until not self.Firing
end
And this is the spring module I’m using.
Have you made sure that your gun isn’t anchored?
Also make sure everything you want to animate has a motor6d, and everything you don’t want animated is welded.
Edit: I think the main part of the gun might have to be welded.
The animation works completely fine, I only started running into problems when I changed my script to use springs to simulate recoil.
Isn’t the BodyAttach suppose be in the HumanoidRootPart?
My apologies but, i also use Headstackk’s Motor6D animation, i mainly use it on humanoidrootpart, i guess reanimating the gun on the bodyattach must be to humanoidrootpart.
Just to clarify, I’m 99% sure the problem is not related to the animation because the animation does work when using other scripts. It just so happens the animation doesn’t work with this new script that uses springs to simulate recoil instead of cframe lerping.
Are you using springs to animate as well, such as the gun bobbing/swaying?
No, I haven’t implemented anything besides spring based recoil
The springs shouldn’t be affecting the animations, since they just move the viewmodels position. Animations are completely seperate and should always work even with springs, so if I were you I would look into the animations segment a little more just to be sure.
For some reason, setting the part0 of the motor6d (the one used to attach the tool to the viewmodel) to the viewmodels head seemed to have fixed the problem.
Ah yeah that’ll do it, If you weld a viewmodel wrong with motor6ds the animations will mess up. Good luck making the rest of the system!