Crouch camera and bobbing help

hey guys i want to add bobbing and swaying effect to my character while its crouching too

im a newbie for camera coding and i cant solve this problem ive tride with changing the hipheight but the caharcter floeats on air for a short time and that causes bugs when spammed so ive came with this choice but i dont know how to do ive tried lerping it kinda worked for run and walk but crouch is problem that ive cant solve

1 Like

You can:

  • Change Humanoid.CameraOffset
  • Use a custom camera
--every frame
local currentTime = time()
Humanoid.CameraOffset = Vector3.new((math.sin(math.cos(currentTime/2)/2)*2)-1, math.cos(currentTime/8)-0.5, 0)

You can play around with the numbers.

1 Like

so how does it work? i want to learn for editing it for my script

1 Like

and how can i make a part that camera follows it
it will work for me too

1 Like

You have to understand a little bit of math that’s going on here: sines and cosines.

Sine waves, are, well, sine waves. Simply, they are waves that go up and down forever. Cosines are the same as sine waves except they are offset. If you combine the two, it can create some cool effects.

The code itself uses these functions to create camera sway by basing it off the time. However, you will need to multiply this value (or the time) by the speed of the character to get it to work effectively instead of just swaying endlessly.

You can change Camera.CameraSubject to the part that you want the camera to follow.

1 Like

oh thanks
i got a last question for you

1 Like

ive tried this method but it breaks the crouch system like as i said

1 Like

Are you saying that at 0:38 the player is still able to stand up even when they aren’t supposed to?

1 Like

yeah the “A” part bugs the touched function i dont know why

1 Like

Use GetTouchingParts instead of .Touched.

1 Like

im thinking to make its name to Head for nicknames ext but

1 Like

but do i write all the parts that you cant unchrouch on the script?

1 Like

yo if i do part c0 of the head and location it to the head bone repeatedy instead of using get touching parts?

1 Like

You can just add a tag to the part.

1 Like

oh ok thanks

30 cdwadasawdwada

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.