(REQ) Subtle Camera Movement

When I was playing PAYDAY: The Heist I noticed that even if you’re standing still the camera slightly moves, so it emulates breathing. I thought it was really neat since it didn’t make the game look dead if you didn’t move your mouse and stared at some part of the map.

I was wondering whether it would be possible, and if possible, to put in Garrysmod: a subtle camera movement that emulates breathing. If it was toggle-able that’d be even better. It would make the game seem more lively instead of frozen if you don’t move the mouse, just a nice subtle touch.

If anyone could get back on this, I’d appreciate it!

this is a rather easy effect to make.
[lua]
hook.Add(“Think”, “PlayerBreathing”, function()
if (!LocalPlayer().HeadMovement) then return; end

local ang = EyeAngles();
local add = math.sin(CurTime());

LocalPlayer():SetEyeAngles( Angle(ang.p + add / 15, ang.y, ang.r) );

end)
[/lua]

this will create a nice relatively realistic slow up/down head movement, and it doesnt move too much.

if its too fast, increase the / 20, if its too slow decrease it. but be warned that the more you increase it, the less the camera will move up and down. the more you decrease it the more it will move up and down.

if you want it to go more than up and down heres how it will work:
[lua]
Angle(up/down, pan left/right, tilt left/right)
[/lua]

enjoy :slight_smile:

[editline]31st July 2012[/editline]

i just realised that with that when you fall from a height and you get the view punch, the camera sticks and its tiled, ill try and work on it :smiley:

[editline]31st July 2012[/editline]

ok i got it heres the new code:

[lua]
hook.Add(“Think”, “PlayerBreathing”, function()
if (!LocalPlayer().HeadMovement) then return; end

local ang = EyeAngles();
local add = math.sin(CurTime());

local newang = ang + Angle(add / 15, 0, 0);

LocalPlayer():SetEyeAngles( newang );

if (EyeAngles().r != 0) then
	ang = EyeAngles();
	LocalPlayer():SetEyeAngles( Angle(ang.p, ang.y, math.Approach(ang.r, 0, 1)) );
end

end)
[/lua]

Would that go in lua/autorun, lua/autorun/client, or lua/autorun/server ? I tried all 3 and there was no effect for me

There was an addon, SharpYe, that did this pretty well.

Is there anyway to increase the idle breathing effect? In terms of speed or distance in bobbing? Without effecting the entire set-up though, just standing still. At the moment its unnoticeable unless you stand right next to something, but thanks.

At the code, do you see a “/ 15”?
decrease that 15, the more you decrease it the more it will move up and down.

I can’t seem to find / 15 anywhere

ye i just said that stillnex and yes its a client side file so autorun/client

I know, I even copied it from your post, but as he apparently didn’t see what you posted, I helped him.

haha fair enough stillnex :stuck_out_tongue:

good god, here

local newang = ang + Angle(add / 15, 0, 0);

Oh, I thought you were speaking about SharpeYe. Sorry about that.

[editline]1st August 2012[/editline]

Thanks, I like it. Appreciate it man.