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.