Disable m_Camera.transform.localPosition = newCameraPosition; in fps controler

Hallo,

I had some problems with my player (FPSControler) by using an escalator. The player was bouncing when using. When disabeling headbob in the inspector of the FPSCotroler it was much better, but when walking it afcourse wasn’t working.
So I searched for how to make this work.
The part I disabled is in the script of the FPSControler is m_Camera.transform.localPosition = newCameraPosition;, see below:

private void UpdateCameraPosition(float speed)
        {
            Vector3 newCameraPosition;
            if (!m_UseHeadBob)
            {
                return;
            }
            if (m_CharacterController.velocity.magnitude > 0 && m_CharacterController.isGrounded)
            {
                m_Camera.transform.localPosition =
                    m_HeadBob.DoHeadBob(m_CharacterController.velocity.magnitude +
                                      (speed*(m_IsWalking ? 1f : m_RunstepLenghten)));
                newCameraPosition = m_Camera.transform.localPosition;
                newCameraPosition.y = m_Camera.transform.localPosition.y - m_JumpBob.Offset();
            }
            else
            {
                newCameraPosition = m_Camera.transform.localPosition;
                newCameraPosition.y = m_OriginalCameraPosition.y - m_JumpBob.Offset();
            }
            // ------Disabled because of bouncing by escalator------
            // m_Camera.transform.localPosition = newCameraPosition;
        }

Now I can use the escalator without an overload of bouncing with the camera.
I tried my game and can’t see any problems, maybe it does with other types of games. Can someone explane what the part m_Camera.transform.localPosition = newCameraPosition; does and why we maybe do need this part.

Allready thanks for the reply.

The function DoHeadBob has to be the problem I think. But it is somethere else, not in the fragment you’re copied, so I cannnot say whats exactly wrong… The line you disabled applies the end result of head bob calculation to camera local position.

Hi DimitriX89,
Thanks for your reply. :slight_smile:
Maybe I should make a script to disable this line (m_Camera.transform.localPosition = newCameraPosition) and make it enabled at the end of the escalator.
that’s a new fun challenge, need to think about that. :roll_eyes: