Hello friends, i need some help.
My task is at a certain moment in time, forcibly, to fix the player’s camera of standart player controller script on a certain object.
After that, the player’s camera needs to remain on the object.
I wrote a script like this. But it does not work correctly. The camera is not positioned correctly after stop fixing. Pls help to find mistake.
private void Update()
{
if (NeedToSeeSmth)
{
m_Camera.transform.rotation = Quaternion.Slerp(m_Camera.transform.rotation, Quaternion.LookRotation(ObjectsForView.transform.position - m_Camera.transform.position), 5f * Time.deltaTime);
transform.rotation =Quaternion.Slerp(transform.rotation,Quaternion.LookRotation(ObjectsForView.transform.position -transform.position), 5f * Time.deltaTime);
NeedLoadRotation = true;
}
else
RotateView();
}
////////
private void RotateView()
{
if (NeedLoadRotation)
{
m_MouseLook.m_CameraTargetRot = m_Camera.transform.rotation;
m_MouseLook.m_CharacterTargetRot = transform.rotation;
m_MouseLook.Init(transform, m_Camera.transform);
NeedLoadRotation = false;
}
m_MouseLook.LookRotation(transform, m_Camera.transform);
}