Advertisement
Guest User

Fintfinkod

a guest
Mar 3rd, 2015
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.73 KB | None | 0 0
  1.     void HeadBob(){
  2.         waveslice = 0.0f;
  3.  
  4.         Vector3 cSharpConversion = cameraTransform.localPosition;
  5.  
  6.         if (currSpeed < 0.3f || (cControllerScript.isGrounded == false)) {
  7.             timer = 0.0f;
  8.         }
  9.         else {
  10.             waveslice = Mathf.Sin(timer);
  11.             timer = timer + bobSpeed * Time.deltaTime;
  12.             if (timer > Mathf.PI * 2) {
  13.                 timer = timer - (Mathf.PI * 2);
  14.             }
  15.         }
  16.         if (waveslice != 0) {
  17.             float translateChange = waveslice * bobAmount;
  18.             float totalAxes = currSpeed;
  19.             totalAxes = Mathf.Clamp (totalAxes, 0.0f, 1.0f);
  20.             translateChange = totalAxes * translateChange;
  21.             cSharpConversion.y = midPoint + translateChange;
  22.         }
  23.         else {
  24.             cSharpConversion.y = midPoint;
  25.         }
  26.         cameraTransform.localPosition = cSharpConversion;
  27.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement