Issue with a Class in Finite State Machine
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 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 state machines goes into the MovingState Class, which handles the movement. This is what I have at the moment:
public override void Update(Animal animal)
{
Debug.Log("Moving...");
animal.lerpTime += Time.deltaTime;
if (animal.lerpTime > animal.lerpTimeMax)
{
animal.lerpTime = animal.lerpTimeMax;
}
animal.transform.position = Vector3.Lerp(animal.lerpOrigin, animal.lerpTarget, animal.lerpTime / animal.lerpTimeMax); //the code that should make the pieces fall
if (animal.transform.position == animal.lerpTarget)
{
//change_move = true; //tried to use a bool to fix the issue
animal.ChangeState(animal.idle);
//Debug.Log("LerpT is LS"); //Prints when uncommented but blocks still aren't moving
}
}
This is her original code:
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!
Your answer
Follow this Question
Related Questions
moving an object continuously between waypoints 0 Answers
C# finding the axis of a characterobject 0 Answers
Need help with limited movement with mathf clamp 2 Answers
c# Mobile Joystick issues - implementing joystick controls into movement and camera script 0 Answers
Bugs on move in air(falling); 0 Answers