I’m working on a 2D simple game, and what I want to ask is I want to make my character follow the path I already made in images object. So, I made a lot of images one by one, and then I put them in the array. I want to make my character to follow them one by one smoothly, but I just can make my character follow one of them. Here is the example :
[125699-capture.png*|125699]
And this is the code for making the character move, I use loop, but it seems like the character just goes to the end of the loop.
public image[] route;
public GameObject character;
private Vector2 startpos;
private float timelerp = 2f;
private float currentlerptime = 0;
void Start()
{
startpos = character.transform.position;
}
void Update()
{
currentlerptime += Time.deltaTime;
if (currentlerptime >= timelerp)
{
currentlerptime = timelerp;
}
float perc = currentlerptime / timelerp;
for (int i=0; i<5; i++)
{
character.transform.position = Vector2.Lerp(startpos, jalur*.transform.position, perc);*
}
}