Headbob camera rotation?

Godot Version 4.2.2.stable

Is it possible to make the camera rotate in the Z Axis on headbob?
i am trying to bring more of a SCP:CB look for the headbob but i just can’t find a way.
i tried animating the headbob but adding a keyframe of the rotation makes your mouse stuck vertically.
any tips?

Your means camera rotates in z axis with mouse?

i mean the camera tilting to the z axis when walking

You can try this:

camera.rotation.z = lerp(camera.rotation.z, -input_dir.x * 0.05, delta * 10.0)

Here 0.05 is the Rotation Amount

I should’ve make this more clear, but i’m trying to make it tilt while walking forward, or all directions in general, as part of the headbob

Do you want to add headbob? Or camera tilt?

I have headbob added, i just want it to inclued tilting to the z axis.

Like when you move forward, camera will tilt to z or x axis?

When moving on all directions, only tilt on z axis but still headbobing

Ok and do you have any video about it I means any game clip that using headbob/camera tilt like yours

There are camera shake assets in the asset library that are based on real-world captures of camera shakes, such as “running with mobile phone”.

here’s what i’m trying to recreate: bob example - Album on Imgur
only problem is the tilting

Hmmm, I saw head bob on z axis, right?

yeah theres headbob on the z axis

Here is the codes, try this:

var vel = Vector2(velocity.x, velocity.z)

if vel > Vector2.ZERO
    camera.rotation.z = lerp(camera.rotation.z, sin(Time.get_ticks_msec() * 0.01) * 0.01, delta * 10.0)
else:
    camera.rotation.z = lerp(camera.rotation.z, 0, delta * 10.0)

Tell me is it working?
If not working, replace the lerp with lerpf

Doesn’t work, i’ll try finding another way

i found a way, here:

var vel = Vector2(velocity.x, velocity.z)

	if vel > Vector2():
		camera.rotation.z = lerpf(camera.rotation.z, sin(Time.get_ticks_msec() * 0.01) * 0.01, delta * 10.0)
	else:
		camera.rotation.z = lerpf(camera.rotation.z, 0, delta * 10.0)

Thank you, one last question, where do i modify the intensity of it?

Yes, I guess lerp will not work,

if vel > Vector2.ZERO
    camera.rotation.z = lerpf(camera.rotation.z, sin(Time.get_ticks_msec() * 0.01) * 0.01, delta * 10.0)
else:
    camera.rotation.z = lerpf(camera.rotation.z, 0, delta * 10.0)

Here the 0.01 in (Time.get_ticks_msec() * 0.01) is the bob frequency and then the 0.01 that multiply the full product is the bob amount, so you can change/adjust it

It works, one last issue, it only works when looking at specific directions or walking to said directions, when i walk to the right while looking forward it works but if i walk forward it doesnt, if i walk forward looking to the right however, it works again, how do i fix that?

Please show the full codes