This commit is contained in:
2022-04-18 16:00:39 +07:00
parent 4bc5cb5ed2
commit 2c58f3a169
1633 changed files with 647860 additions and 0 deletions

View File

@ -0,0 +1,45 @@
using System;
using System.Collections;
using UnityEngine;
namespace UnityStandardAssets.Utility
{
[Serializable]
public class LerpControlledBob
{
public float BobDuration;
public float BobAmount;
private float m_Offset = 0f;
// provides the offset that can be used
public float Offset()
{
return m_Offset;
}
public IEnumerator DoBobCycle()
{
// make the camera move down slightly
float t = 0f;
while (t < BobDuration)
{
m_Offset = Mathf.Lerp(0f, BobAmount, t/BobDuration);
t += Time.deltaTime;
yield return new WaitForFixedUpdate();
}
// make it move back to neutral
t = 0f;
while (t < BobDuration)
{
m_Offset = Mathf.Lerp(BobAmount, 0f, t/BobDuration);
t += Time.deltaTime;
yield return new WaitForFixedUpdate();
}
m_Offset = 0f;
}
}
}