We use cookies on this site to enhance your user experience
Collapse Sidebar




CameraOffset specifies an offset to the Camera’s subject position when its CameraSubject is set to this Humanoid.

The offset is applied in object-space, relative to the orientation of the Humanoid’s HumanoidRootPart.

Code Samples

Walking Camera Bobble Effect

This LocalScript makes the camera bobble as the player’s character walks around, utilizing both the Humanoid’s CameraOffset and MoveDirection.
It should be parented inside of the StarterCharacterScripts so that it is distributed into a player’s character as expected.

local RunService = game:GetService("RunService")

local playerModel = script.Parent
local humanoid = playerModel:WaitForChild("Humanoid")

local function updateBobbleEffect()
	local now = tick()
	if humanoid.MoveDirection.Magnitude > 0 then -- Are we walking?
		local velocity = humanoid.RootPart.Velocity
		local bobble_X = math.cos(now * 9) / 5
		local bobble_Y = math.abs(math.sin(now * 12)) / 5
		local bobble = Vector3.new(bobble_X,bobble_Y,0) * math.min(1, velocity.Magnitude / humanoid.WalkSpeed)
		humanoid.CameraOffset = humanoid.CameraOffset:lerp(bobble,.25)
		-- Scale down the CameraOffset so that it shifts back to its regular position.
		humanoid.CameraOffset = humanoid.CameraOffset * 0.75

-- Update the effect on every single frame.