Lizard Attack Animation Issue

Did everything the same as the lecture, the transition time is zero, Exit time also uncheck. Whenever I hit the IsAttack bool option instead of direct transition from walk to Attack and vice versa, The jump animation playing between walk and attack every time. Not find any reason for this. Does anyone have the same issue in lecture 45 of glitch Gaden?

Hi Daniyal,

Have you already compared your code to the Lecture Project Changes which can be found in the Resources of this lecture? If so, add Debug.Logs to your code to see what’s going on during runtime.

Hi Nina, The issue is not in code. The issue is in animation wish I could post a video here. Not find any option.

Please watch this .

I cannot see any problem. Select one of the spawned Lizards in the Hierarchy, then tick the bool property in the animator. If no object is selected, the animator window is the global animator window.

When I click on Lizard prefab and then tike the IsAttacker property then this issue occurs which is posted above that jump animation run between walk and attack all the time. But when I click on individual Lizard clone from the hierarchy then animation worked fine on that individual clone but can’t tick bool property then. Checked other questions regarding the lecture and found out that some other people also face the same issue but no one found out a proper solution. I think it has something to do with spawners because the same type of animation method worked fine on other Attackers.

Could this be caused by a reference issue? Check your code. Does it call FindObjectOfType instead of GetComponent.

If it’s not the code, click on the transition arrows in your animator and share screenshots. Expand the box with Transition Duration(s).

Do not click on the Lizard prefab. The clone in the Hierarchy must be selected.

Now I disable the spawner object and use just 1 lizard object in the scene.

Now I removed all scripts from the Lizard object and it worked perfectly fine now, which means there is no issue in animation.

Now it must be something wrong with the code which I already verified but no found any issue.

Here is my Attacker script :

[Range(0f, 5f)]
[SerializeField] float currentSpeed;
GameObject currentTarget;

// Start is called before the first frame update
void Start()

// Update is called once per frame
void Update()
    transform.Translate(Vector2.left * currentSpeed * Time.deltaTime);

public void SetMovementSpeed(float speed)
    currentSpeed = speed;

private void UpdateAnimationState()
    if (!currentTarget)
        GetComponent<Animator>().SetBool("IsAttacker", false);

public void Attack(GameObject target)
    GetComponent<Animator>().SetBool("IsAttacker", true);
    currentTarget = target;

public void StrikeCurrentTarget(float damage)
    if(!currentTarget) { return; }
    Health health = currentTarget.GetComponent<Health>();
    if (health)


Here is my Lizard script :

private void OnTriggerEnter2D(Collider2D otherCollider)

    GameObject otherObject = otherCollider.gameObject;

    if (otherObject.GetComponent<Defender>())




This is AttackerSpawner script

SerializeField] float minSpawnDelay = 1f;
[SerializeField] float maxSpawnDelay = 5f;
[SerializeField] Attacker attackerPrefab;

bool spawn = true;

IEnumerator Start()
    while (spawn)
        yield return new WaitForSeconds(Random.Range(minSpawnDelay, maxSpawnDelay));

private void spawnAttacker()
  Attacker newAttacker =  Instantiate
 (attackerPrefab,transform.position, Quaternion.identity)
 as Attacker;

    newAttacker.transform.parent = transform;


The issue is that I didn’t enable “IsTrigger” :man_facepalming: :man_facepalming: unbelievable

Anyways the transition is working now from walking to attacking but Lizards behave very awkwardly some are sliding and some triggered even though there is not any defender. I add animation events on the right places and I didn’t use “objectsOfType” so don’t understand why this is happening to lizards.

Oops. At least you found and fixed a problem. :slight_smile:

Where do the Attack and the SetMovementSpeed methods get called? In an animation event? If so, check your animations again. The speed must be set to 0 in the attack animation, and it must be set to a higher value in the walk animation.

If you cannot spot any issue there, share screenshots of the Inspector of the animation states. Click on the animation arrows. Expand all menus in the Inspector so “Transition Duration(s)” is visible.

In your video, the gravestone is overlapping the lane above its own lane. That’s why two lizards start attacking it.

I set MovementSpeed to 1 in the “walk” animation and 0 in the “Attack” animation so that part is not an issue for sure.

Here is the inspector of animations.



The version 2018.2 which is used by Sir Rick for the lectures has Transition Offset value “0” by default. But the version which is I use 2019.4.9 have some small value in it by default instead of “0” this is the tiny issue which ate my 4,5 days :astonished:

Glad finally it resolved . Thank you Nina for pointing out transitions every time I make transition duration 0 and exit time also uncheck at the first place so confident that issue must be somewhere else.

Now as far as position of gravestone, there is not any overlapping Nina. I even set the position of the gravestone again still the issue is same the lizard above the lane of gravestone started attacking it. Please elaborate if you see it in a different way.

Fox started eating the invisible defender, Lizards of both lanes above and below triggered and make a queue as they pray for the dead :sweat_smile:

The problem was the “Lizard Attacker” collider was triggered in the layer above and below by the collision of their own colliders. So I edit colliders and make them very small so they just trigger when any defender comes in front of Attacker.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms