So what is happening is that everytime I change the camera angle, it changes the character movement direction. For example, i was W to move forward and when I Change the camera angle, my character moves left even though im still pressing W
Heres the code:
local module = {}
local knit = require(game.ReplicatedStorage.Packages.Knit)
local controller = knit.GetController("CameraController")
local types = require(script.Parent.Types)
module.presets = {
["ShootSmall"] = {
Power = 10;
X_Influence = 0.15;
Y_Influence = 0 ;
Z_Influence = 0.15;
X_AngleInflueunce = 2;
Y_AngleInflueunce = 2;
Z_AngleInflueunce = 2;
InfluencePower = 1;
}
}
local abs = math.abs
local rad = math.rad
local camera = workspace.CurrentCamera
function module.shakeCamera(presetaaaa:string)
task.spawn(function()
local presetSettings = module.presets[presetaaaa]
local rn = Random
for i = 1,presetSettings.Power do
local xAngle = rn.new():NextNumber(-abs(presetSettings.X_AngleInflueunce),abs(presetSettings.X_AngleInflueunce))
local yAngle = rn.new():NextNumber(-abs(presetSettings.Y_AngleInflueunce),abs(presetSettings.Y_AngleInflueunce))
local zAngle = rn.new():NextNumber(-abs(presetSettings.Z_AngleInflueunce),abs(presetSettings.Z_AngleInflueunce))
camera.CFrame *= CFrame.new(xAngle,yAngle,zAngle)
controller.AdditionalRotation.X = xAngle
controller.AdditionalRotation.Y = yAngle
controller.AdditionalRotation.Z = zAngle
game["Run Service"].Heartbeat:Wait()
end
controller.AdditionalRotation.X = 0
controller.AdditionalRotation.Y = 0
controller.AdditionalRotation.Z = 0
end)
end
return module
function cameraController:update()
if camera.CameraType ~= Enum.CameraType.Scriptable then
camera.CameraType = Enum.CameraType.Scriptable
end
cameraController.Zoom = math.clamp(cameraController.Zoom,cameraController.Min_Zoom,cameraController.Max_Zoom)
local pos = uis:GetMouseLocation()
local offset_x = (pos.X/camera.ViewportSize.X) - 0.5
local offset_y = (pos.Y/camera.ViewportSize.Y) - 0.5
local char = plr.Character
local root = char:FindFirstChild("HumanoidRootPart")
camera.CFrame = camera.CFrame:Lerp(CFrame.new(root.Position + Vector3.new(0,cameraController.Zoom,0),root.Position) * CFrame.Angles(0 + rad(self.AdditionalRotation.Z),0 + rad(self.AdditionalRotation.Y),math.pi/2 + rad(self.AdditionalRotation.X)) * CFrame.new(offset_x * cameraController.MouseOffset_Unit,-offset_y * cameraController.MouseOffset_Unit,0),0.75)
end