So I’ve been working on a simple gun system, yet making the weapon point towards where the player has their mouse at has given me a bit of a headache.
You see, currently I’ve just stolen the code for pointing the arm (R6) from the laser pointer tool and modified it a bit, yet in my case, the walking & running animations (which are not the default ones) interfere with the pointing, as seen in the video below.
(The gun is not supposed to move around. It’s supposed to only point towards where I’m pointing)
The code is fairly simple, albeit not entirely written by me.
I’ve tried countering the animation by multiplying angles with CFrame.Angles(0, 0, -shoulder.CurrentAngle) in the code, and that did dampen the interference, however it’s still very visible. Because I was able to dampen it a bit, I think it should be possible to fully get rid of the swaying if done correctly.
So essentially I’m hoping that anyone here knows how to properly implement the arm pointing thing without it getting interfered by animations.
Hopefully someone who has some more experience than me with such things can help me out here.
Thank you in advance C:
I’ll be honest Im nit the best with this either, but is it possible for you to reset the arm and disable those lines before the sprinting animation starts? And then when you’re done sprinting re-enable the code
If I understand you correctly, you are proposing that I’d stop the pointing code while I’m sprinting?
But I’m trying to stop the sprinting animation from interfering with the pointing code, instead of stopping the pointing code from interfering with the animations.
I want only the pointing to be visible. I wish to cancel out any animation that is controlling the hand while I’m trying to make it point.
I’ve also tried just settings the shoulder.CurrentAngle to 0 on every RunService event, yet none of them changed anything and the animation continued as if I hadn’t even tried to stop it.
I’m not sure how optimized this is (performance or organizational wise) but what if you did an animation where the right hand was not animated at all when a tool is equipped? I know this might be a little redundant but I’m not sure if there’s a way to stop the right arm from animating unless the animation doesn’t animate the right arm.
Unfortunately that would require me to create a new animation for each movement animation. It should be possible to be cancel the effects of the animation by code, but I got a similar idea myself that might work. What if I created a very high priority animation that just kept the arm still? Perhaps that’d work. I might try that later, but currently I’m hoping that another approach is also possible.