So I modified my camera (simple screen shake) and i wanted to make camera even more dynamic with attaching it to torso
It looks like this:
But it looks weird so i wanted to move camera Y axis little higher to make it look like default roblox camera:
(I hope yall see difference lol)
I tried to get it with changing CameraOffset like that, putting it in RenderStepped or outside didnt do any effect:
humanoid.CameraOffset = Vector3.new(0,10,0)
Allat in local script inside of StarterCharacterScripts
Code:
local runService = game:GetService("RunService")
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local camera = workspace.CurrentCamera
local torso = character:WaitForChild("Torso")
camera.CameraSubject = torso
function updCameraShake()
local currentTime = tick()
local strength = nil
if humanoid.WalkSpeed > 11 then
strength = .065
elseif humanoid.WalkSpeed <= 11 then
strength = .03
end
if humanoid.MoveDirection.Magnitude > 0 then
local shakeX = math.cos(currentTime * 10) * strength
local shakeY = math.abs(math.sin(currentTime * 10)) * strength
local shake = Vector3.new(shakeX, shakeY, 0)
humanoid.CameraOffset = humanoid.CameraOffset:lerp(shake, .25)
else
humanoid.CameraOffset = humanoid.CameraOffset * .7
end
end
runService.RenderStepped:Connect(updCameraShake)