I allready have a working code to achieve a slow mo effect… It falls down and then up- but, I think it can be made way cooler by someone who understands coroutines and lerp properly (this person is not me);
How could I implement an effect similar to this one by using Lerp or Slerp? thank you for the help
public class TimeManipulation : MonoBehaviour {
KeyCode timeManipualtionKey;
public bool manipulatingTime;
public bool manipulatingDown;
public bool manipulatingUp;
public float manipulationRate;
public float timeManipulationDown = .5f;
public float lerpSpeed = 10;
public float durationOfManipulation = 2;
float it = 1;
float increment = .05f;
void OnEnable()
{
timeManipualtionKey = this.GetComponent<Attributes> ().timeManipulation;
}
// Update is called once per frame
void FixedUpdate () {
if (Input.GetKeyDown (timeManipualtionKey)) {
manipulatingTime = true;
manipulatingDown = true;
}
if (manipulatingTime) {
if (manipulatingDown) {
if (it >= .5f) {
print ("manipulating Down");
it -= increment;
Time.timeScale = it;
Time.fixedDeltaTime = 0.02f* Time.timeScale;
} else {
print ("finished manipulation Down");
manipulatingDown = false;
StartCoroutine (TimeInTheZone ());
}
}
if (manipulatingUp) {
if (it <= 1) {
print ("starting manipulating up");
it += increment;
Time.timeScale = it;
Time.fixedDeltaTime = 0.02f * Time.timeScale;
} else {
print ("manipulation ended");
manipulatingUp = false;
manipulatingTime = false;
}
}
}
}
IEnumerator TimeInTheZone()
{
print ("starting wait");
yield return new WaitForSeconds (1);
print ("wait ended");
manipulatingUp = true;
yield return null;
}
}