DictatorPanda
Coder
Good day/night! I've been working on making a Match 3 game in Unity for a project and I'm 99% done but there is an issue. After the player makes a match, the pieces aren't falling to fill the empty squares and I'm not sure what the reason is. Disclaimer: This is a HW assignment where I had to turn an enum to a finite state machine. It's basically done, but I only have this issue. I'm not asking anyone to do the assignment for me. As I said before, I did it. I just have this error and wanted to get another set of eyes to view the code and point out anything off about it.
Currently after the player makes a match, the pieces aren't falling down for some reason. The class that's supposed to handle it is the MovingState Class and this is what I have at the moment:
This is her original code.:
I made sure not too make too many changes to her code since it did the job, but I'm not sure what I'm doing wrong. I noticed that in her original code it did change the state back to idle after the conditional. I tried that, but it didn't work either. Any tips or tutorials are appreciated!
Currently after the player makes a match, the pieces aren't falling down for some reason. The class that's supposed to handle it is the MovingState Class and this is what I have at the moment:
C#:
public override void Update(Animal animal)
{ //Animal refers to the Animal Class where the states are put into action
Debug.Log("Moving...");
animal.lerpTime += Time.deltaTime;
if (animal.lerpTime > animal.lerpTimeMax)
{
animal.lerpTime = animal.lerpTimeMax;
//animal.ChangeState(animal.idle);
}
if (animal.lerpTimeMax != 0) //Prevents an invalid input error
{
//shrinks the game objs
animal.transform.localScale = Vector3.Lerp(animal.lerpOrigin, animal.lerpTarget, animal.lerpTime / animal.lerpTimeMax);
}
if (animal.transform.localScale == animal.lerpTarget)
{
change_move = true; //This bool was declared in the beginning of the class so it's not the issue
//Debug.Log("LerpT is LS");
}
if (change_move)
{
animal.ChangeState(animal.idle);
change_move = false;
}
}
This is her original code.:
C#:
if (State == AnimalState.Moving) //using an enum
{
lerpTime += Time.deltaTime;
if (lerpTime > lerpTimeMax)
{
lerpTime = lerpTimeMax;
State = AnimalState.Idle;
}
transform.position = Vector3.Lerp(lerpOrigin, lerpTarget, lerpTime / lerpTimeMax);
}
I made sure not too make too many changes to her code since it did the job, but I'm not sure what I'm doing wrong. I noticed that in her original code it did change the state back to idle after the conditional. I tried that, but it didn't work either. Any tips or tutorials are appreciated!