Basically I'm creating an fps and I wanted to know why my character flings when I look around.
https://gyazo.com/cc6c2605d3379add8ca4e7e2216e6eab <GIF
Basically I have a custom rig with a humanoid, arms, torso and the gun, and I attach it to the camera. I thought maybe something can collide with my character and that would cause me to fling but of what I can see that's not the issue.
https://gyazo.com/1e7f4c25f3e14a224fb2101adde466e1 <PIC
Also I like how I do things as of now and that I only want to know why and how to fix the flinging, the rig with the gun in it is easy to animate and saves a lot of time where I would be doing trial and error to figure out where to put the hands and the gun.
Code and Resources Below
local Player = game.Players.LocalPlayer
local Char = script.Parent
local Camera = workspace.Camera
local Run = game:GetService("RunService")
local Body = game.ReplicatedFirst.CameraBody:Clone()
local Input = game:GetService("UserInputService")
--local Gun = game.ReplicatedFirst.Gun
Run.RenderStepped:Connect(function()
Body.HumanoidRootPart.CFrame = Camera.CFrame
end)
Body.Parent = Camera
--Gun.Parent = Camera
IdleAnimation = Instance.new("Animation"); IdleAnimation.AnimationId = "rbxassetid://4597725243"; PlayIdle = Body.Humanoid:LoadAnimation(IdleAnimation)
ReloadAnimation = Instance.new("Animation"); ReloadAnimation.AnimationId = "rbxassetid://4598138817"; PlayReload = Body.Humanoid:LoadAnimation(ReloadAnimation)
FireAnimation = Instance.new("Animation"); FireAnimation.AnimationId = "rbxassetid://4598142234"; PlayFire = Body.Humanoid:LoadAnimation(FireAnimation)
PlayIdle:Play()
Input.InputEnded:Connect(function(inputObject, gameProcessedEvent)
if gameProcessedEvent then return end
if inputObject.UserInputType == Enum.UserInputType.Keyboard then
if inputObject.KeyCode.Name == 'R' then
PlayReload:Play()
end
if inputObject.KeyCode.Name == 'F' then
PlayFire:Play()
end
end
end)

1 comment
Also the flinging is very random, its not rare but its hard to replicate, I luckily got it on my first try.