Other
How to fix animation delay in grid based game.
I've set up a script for a 2D grid based game. My problem is when i set up the player animation, it will either not work at all or if I change the exit time, fixed duration and/or transition duration in the animator then the animation will partly play but will be delayed.
Here is the animation. https://imgur.com/k3945JC
Here is the script. https://imgur.com/a/gbxNh
And here are the variables in the animator. https://imgur.com/a/3GZuL
MoveX, MoveY, LastMoveX, LastMoveY, PlayerMoving.
One thing I noticed is the PlayerMoving bool in the animator shows as true for a split second even while holding an arrow key to move and then is set to false again.
How do I fix it so that when I move in a direction, the animation for that direction will play normally and without delay?
Player$$anonymous$$oving is reset to false at the beginning of every frame. you should set it to false when the player has reached it's target position
This is what i did.
transform.position = Vector3.$$anonymous$$oveTowards(transform.position, pos, Time.deltaTime * speed);
if(transform.position == Vector3.$$anonymous$$oveTowards(transform.position, pos, Time.deltaTime * speed))
{
player$$anonymous$$oving = false;
}
It seems to be working now but the player looks down during the middle of all the animations and that isn't a part of the animation clips. That's odd.
Follow this Question
Related Questions
How to Apply Animation to Player 0 Answers
How do I apply an animation to a sprite? 0 Answers
GameObject disappears on Animation transition 0 Answers
Animation Constantly Playing? 1 Answer
nullException for animator states 0 Answers