Hey, guys! I am trying to get rid of delay when my gameobject goes from state FireFlyStrafe back to state FireFlyIdle. I checked a lot of issues with animation delay but still can’t make my own work as planned. Here’s code I use to control states and pictures of transitions between states. I am flipping strafe animation in my code.
using UnityEngine;
using System.Collections;
public class FiryFlyAnimCtrl : MonoBehaviour {
private Animator anim;
bool facingRight = true;
bool set = false;
void Start()
{
anim = GetComponent<Animator>();
}
void Update()
{
float move = Input.GetAxis("Horizontal");
anim.SetFloat("SpeedHorizontal", Mathf.Abs(move));
if (move > 0 && !facingRight)
{
Flip();
}
if (move < 0 && facingRight)
{
Flip();
}
}
private void Flip()
{
facingRight = !facingRight;
Vector3 scale = transform.localScale;
scale.x *= -1;
transform.localScale = scale;
}
}