Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void HeadBob(){
- waveslice = 0.0f;
- Vector3 cSharpConversion = cameraTransform.localPosition;
- if (currSpeed < 0.3f || (cControllerScript.isGrounded == false)) {
- timer = 0.0f;
- }
- else {
- waveslice = Mathf.Sin(timer);
- timer = timer + bobSpeed * Time.deltaTime;
- if (timer > Mathf.PI * 2) {
- timer = timer - (Mathf.PI * 2);
- }
- }
- if (waveslice != 0) {
- float translateChange = waveslice * bobAmount;
- float totalAxes = currSpeed;
- totalAxes = Mathf.Clamp (totalAxes, 0.0f, 1.0f);
- translateChange = totalAxes * translateChange;
- cSharpConversion.y = midPoint + translateChange;
- }
- else {
- cSharpConversion.y = midPoint;
- }
- cameraTransform.localPosition = cSharpConversion;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement