Hello to all. Recently I have been trying to make an fps game from scratch however I am having an issue with making the gun to idle animate while also the character is moving their hands cooresponding to the camera’s Y axis movement. When an animation is being played I found out that I am unable to rotate the arm’s Motor6D’s correctly and I think that’s what is causing the animation to work incorrectly, however I have no clue how to fix it. Here is the script that Tilts the head and Arms.
local neckC0 = CFrame.new(0, 0.8, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1);
local waistC0 = CFrame.new(0, 0.2, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1);
local rShoulderC0 = CFrame.new(1, 0.5, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1);
local lShoulderC0 = CFrame.new(-1, 0.5, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1);
game.ReplicatedStorage.Remotes.tiltAt.OnServerEvent:Connect(function(player, theta)
local neck = player.Character.Head.Neck;
local waist = player.Character.UpperTorso.Waist;
local rShoulder = player.Character.RightUpperArm.RightShoulder;
local lShoulder = player.Character.LeftUpperArm.LeftShoulder;
neck.C0 = neckC0 * CFrame.fromEulerAnglesYXZ(theta*0.5, 0, 0);
waist.C0 = waistC0 * CFrame.fromEulerAnglesYXZ(theta*0.5, 0, 0);
rShoulder.C0 = rShoulderC0 * CFrame.fromEulerAnglesYXZ(theta*0.5, 0, 0);
lShoulder.C0 = lShoulderC0 * CFrame.fromEulerAnglesYXZ(theta*0.5, 0, 0);
end)
This piece of code can be found in one of the tutorials of EgoMoose. Here is the link: The First Person Element Of A First Person Shooter
You can check what my intentions were there for using that piece of code.
As for the calling of the function I am using this piece of code:
RotationVal = math.asin(workspace.CurrentCamera.CFrame.LookVector.y)
if RotationVal > .75 then
RotationVal = .75
elseif RotationVal < -.75 then
RotationVal = -.75
end
game.ReplicatedStorage.Remotes.tiltAt:FireServer(RotationVal);
Of course the function is done in a RenderStepped event.
The if statement I added was just to keep the character rotate the head and arms to positions that did not look crazy as to rotating them to 70-90 degrees directly.
I would also like to hear if you have any other ways of doing it!
Thanks in advance for any help!