I’ve tried that, but you cant apply any changes to the camera without it being scriptable but i still want the camera to have the same position
why you should do is
local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable
Then from there do UIS to get when the player does a or d then you know how to tilt the cam.
Can you stick two parts on either side of the player somehow and do a while loop to make the camera CFrame in the parts depending on which key is pressed? That way if the player moves the part follows so the camera should update its position similarly to Enum.CameraType.Custom
Those parts would add difficulties in themselves, and if the player dies then you need to think about stuff like that.
He wants to have the camera follow the player so Enum.CameraType.Scriptable by default would leave the camera stuck.
In some cases it does, but this is just a glitch
I got it working, im gonna add some cframe lerping but other than that it works fine scorpions idea to use parts helped because that helped me figure out the rotation, but thanks everyone that responded.
if your want the code here it is:
local camera = workspace.Camera
local player = game:GetService("Players").LocalPlayer
local char = player.Character or player.CharacterAdded:wait()
local runService = game:GetService("RunService")
runService.RenderStepped:connect(function()
local humanoid = char:FindFirstChild("Humanoid")
if humanoid then
local a = false
local x,y,z = camera.CFrame:ToEulerAnglesXYZ()
if game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.A) then
a = true
camera.CFrame = CFrame.new(camera.CFrame.Position) * CFrame.Angles(x,y,z) * CFrame.Angles(0,0,math.rad(2))
end
if game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.D) then
a = true
camera.CFrame = CFrame.new(camera.CFrame.Position) * CFrame.Angles(x,y,z) * CFrame.Angles(0,0,math.rad(-2))
end
if a == false then
camera.CFrame = CFrame.new(camera.CFrame.Position) * CFrame.Angles(x,y,z)
end
end
end)
local runService = game:GetService(“RunService”)
local character = script.Parent
local humanoid = character:WaitForChild(“Humanoid”)
function updateBobbleEffect()
local currentTime = tick()
if humanoid.MoveDirection.Magnitude > 0 then – we are walking
local bobbleX = math.cos(currentTime * 10) * .35
local bobbleY = math.abs(math.sin(currentTime * 10)) * .35
local bobble = Vector3.new(bobbleX, bobbleY, 0)
humanoid.CameraOffset = humanoid.CameraOffset:lerp(bobble, .25)
else -- we are not walking
humanoid.CameraOffset = humanoid.CameraOffset * .75
end
end
runService.RenderStepped:Connect(updateBobbleEffect)
this script makes the camera shake when the player walks but if you change it, it wall do what you want.
Oh ok, that’s great to hear!
…
How do i make when i hold Q or E then i pressed A or D the camera moves to left or right
im trying to make like 3DMG camera system
Please open a separate post for this.
i did here the link:
mobile and console devices don’t have keyboards to detect keyboard input
Do you know how you can make it smooth
Please open a new topic for this.
Use :Lerp() to smoothly interpolate the CFrame
Sorry to bump this old post, but
How can you use :Lerp() to interpolate a camera’s CFrame? If you do a for loop, the camera will force you into that position until the for loop is done.
You could use game:GetService("UserInputService"):GetMouseDelta()
to find the change in pixels with the mouse. That way you can add mobile support and change the tilt depending on the speed they move.
Something along the lines of this would fix that
local cam = workspace.CurrentCamera
local cf = cam.CFrame
local setcf -- cframe value to lerp the cf variable to
local t = 0.2 -- how long the lerp interpolation is
local runservice = game:GetService("RunService")
runservice.RenderStepped:Connect(function()
cam.CFrame *= cf:Lerp(setcf, t)
end)
Basically it keeps the original CFrame of the camera, but also offsets it with the “cf” variable; which interpolates from one value to another.
Sorry if it doesn’t work it’s 2 am for me right now I’m bad at explaining things, but I hope this helps