Camera breathing effect?

I’m trying to get a realistic breathing effect in First Person
I tried attaching the camera to the players torso or head, it did work, but not in the way intended. It makes the player’s body visible and makes the camera controls all weird.

local player = game.Players.LocalPlayer
local cam = game.Workspace.CurrentCamera

cam.CameraSubject = player.Character.Head
cam.CameraMode = Enum.CameraMode.LockFirstPerson

Is there a better way to make the camera have a breathing effect?

4 Likes

I’m not good with visualizing math as others, an example of this would be games like Call of Duty. The camera bobs in a breathing motion, even when sitting idle.

1 Like

For my GCC game, I looped using CameraOffset to move the camera up/down to get a breathing/stride movement, you might be able to use this to accomplish what you want, too.

That worked! Only one problem though, when panning the camera in first person, it’s really choppy.

distance = .01
speed = .01

player = game.Players.LocalPlayer
humanoid = player.Character:WaitForChild("Humanoid")


RenderStepped = game:GetService'RunService'.RenderStepped


while true do
	RenderStepped:wait()
	humanoid.CameraOffset = humanoid.CameraOffset
	
	+ Vector3.new(distance * math.sin(tick() - 1 + speed ),distance * math.sin(tick()),
			distance * math.sin(tick() - 1 + speed )
		)
end

I’m not really sure what to do about choppiness, sorry. Really the only experience I’ve had with CameraOffset is for that game, and I was rushing to make that in about the last week and a half of the contest so I basically found something that worked, made it as quickly as possible, and moved on. :stuck_out_tongue:

I figured it out. :slight_smile:

Thanks for pointing out CameraOffset to me, frankly I had no idea it existed.
Anyway, here is the script for those who would like to have it.

distance = .005
speed = 5

player = game.Players.LocalPlayer
humanoid = player.Character:WaitForChild("Humanoid")


RenderStepped = game:GetService'RunService'.RenderStepped

while true do
		RenderStepped:wait()
		humanoid.CameraOffset = humanoid.CameraOffset
			+ Vector3.new(0,distance * math.sin(tick() - 0.1 * speed), 0)
	end
10 Likes

If the camera gets choppy, just use the offset as a placeholder, but then use cam:Interpolate(CamPos,CamFocus,timeBetween) where the camera is the offset, and the camfocus is where the mouse is, and also the timeBetween is really small, like .03. This makes it really smooth.