I’m currently trying to add aiming down sights to my weapon system I’ve started working on recently. My issue is weird Motor6D behavior that I’ve encountered, when I’m trying to adjust Arms rotation accordingly to difference between Y axis of Camera and Torso LookVectors (Angle variable) - the arm starts spinning instead of just moving to the desired angle.
Function caller:
RenderConnection = RunService.RenderStepped:Connect(function() AimEvent:FireServer(Camera.CFrame.LookVector.Y - Character.Torso.CFrame.LookVector.Y, State) end)
Function on server that’s supposed to rotate arms:
AimEvent.OnServerEvent:Connect(function(Player, Angle, State)
local Character = Player.Character
if State == true then
if Aiming == false then
Aiming = true
AimAnimation:Play()
IdleAnimation:Stop()
end
local CurrentC0 = Character.Torso["Right Shoulder"].C0
local X, Y, Z = CurrentC0.Rotation:ToEulerAnglesXYZ()
local NewRotation = CFrame.Angles(X, Y, Angle)
local NewC0 = CFrame.new(CurrentC0.Position) * NewRotation
Character.Torso["Right Shoulder"].C0 = NewC0
elseif State == false and Aiming == true then
Aiming = false
AimAnimation:Stop()
IdleAnimation:Play()
end
end)
Spinning:
I’m using Angle as Z instead of Y because animation thats also in place during ADS seems to be replacing these 2 with each other.
When using Angle as different axis it works but the arm isnt factually moving on the right axis (For example moves right and left when used on Y).
It seems to me like the Motor6D is getting adjusted by value instead of set to value each iteration but I have no idea how thats possible. Any help appreciated!