I have an 2D array which stores the transforms of a gameobject at every frame. My requirement is that when the gameobject reaches a checkpoint, the gameobject should go back to the first value and go through the same path again, but it doesn’t have to be at a linear speed. Rather, it should start to speed up towards the end. I’m able to successfully make the gameobject go through the exact motion but unable to make it speed up towards the end. I basically wish to change the interpolation of how the array be able to speed up through its’ values. The below is the snippet of how I’m making the gameobject go through the values stored inside the array at a linear speed.
myTrans tp = new myTrans (); //create temp variable our class
tp.myPos = this.transform.position; //save current position
tp.myQuat = this.transform.rotation; //save current rotation
tp.myScale = this.transform.localScale; //save current scale
Movements.Add (tp); //add current data in our list
MovementIndex++;
//This part above saves the values inside the array
MovementIndex++;
if (MovementIndex >= 0 && Movements.Count > 0) {
this.transform.position = Movements[MovementIndex].myPos;
this.transform.rotation = Movements[MovementIndex].myQuat;
this.transform.localScale = Movements[MovementIndex].myScale;
}
//This part above goes through the values inside the array making the object to go through the same path as before.