This commit is contained in:
2022-09-10 15:38:17 +03:00
parent 1e05c48ca6
commit e879f36b29
6 changed files with 194 additions and 187 deletions

View File

@@ -15,6 +15,9 @@ public class CameraBob : MonoBehaviour
CharacterController controller;
public bool IsRotating = false;
//public int XRotStop = 1000;
//public int YRotStop = 1000;
Vector3 StartPos;
Quaternion StartRot;
@@ -57,25 +60,26 @@ public class CameraBob : MonoBehaviour
if (!IsRotating)
PlayMotion(FootStepMotion());
else
PlayMotion(FootStepRotation());
return;
//PlayMotion(FootStepRotation());
}
Vector3 FootStepMotion()
{
Vector3 pos = Vector3.zero;
pos.y += Mathf.Sin(Time.time * Frequency) * Amplitude;
pos.x += Mathf.Cos(Time.time * Frequency / 2) * Amplitude *2;
pos.y += Mathf.Cos(Time.time * Frequency) * Amplitude;
pos.x += Mathf.Sin(Time.time * Frequency / 2) * Amplitude *2;
return pos;
}
/*
Quaternion FootStepRotation()
{
Quaternion pos = new Quaternion(0,0,0,0);
pos.y += Mathf.Sin(Time.time * Frequency) * Amplitude;
pos.x += Mathf.Cos(Time.time * Frequency / 2) * Amplitude * 2;
pos.y += Mathf.Sin(Time.time * Frequency) * (Amplitude / YRotStop);
pos.x += Mathf.Cos(Time.time * Frequency / 2) * (Amplitude / XRotStop);
return pos;
}
*/
void ResetPosition()
{
if (!IsRotating)
@@ -86,6 +90,7 @@ public class CameraBob : MonoBehaviour
else
{
if (Camera.localRotation == StartRot) return;
Camera.localRotation = Quaternion.Lerp(Camera.localRotation, StartRot, Time.deltaTime);
}
}

View File

@@ -50,16 +50,16 @@ public class CameraMovement : MonoBehaviour
}
}
IEnumerator PauseGame()
IEnumerable PauseGame()
{
SceneManager.LoadSceneAsync("pause", LoadSceneMode.Additive);
Time.timeScale = 0;
return null;
}
IEnumerator UnPauseGame()
IEnumerable UnPauseGame()
{
SceneManager.UnloadSceneAsync("pause" );
SceneManager.UnloadSceneAsync("pause");
Time.timeScale = 1;
return null;
}