Movement on 1st Sprite of Animation Only

I’ve successfully created two Attackers that move as expected, however, my 3rd one is not behaving as I expect it to. The one with a simple “move left” animation that works is “Bat”. The other one, “Skeleton”, only jerks forward with the first sprite of the animation, while remaining in place for the remaining 3 sprites. Any insight into why this is happening would be greatly appreciated.

Here is the set up of Bat:


And here is the set up of Skeleton:


And here is the Attacker script for the SetMovementSpeed method:

Hi Charly,

Please check the transitions in your animator. Click on the arrow between the animation states. The Transition Duration value must be set to 0.

Hi Nina,

At present there is only one animation, so there aren’t any transitions but the default:


Screenshot 2021-04-18 113651

It’s very strange that the enemy starts slowly and suddenly speeds up. I’m wondering how often SetMovementSpeed gets called. Please log a message along with Time.frameCount, GetInstanceID() and speed into your console.

Also disable the EnemySpawner object for a moment and place a single enemy in your scene for testing purposes. I’m wondering if the problem is part of the prefab or caused by something else.

Hi Nina,

Before I submitted a question, I did delete the original prefab and recreated it from scratch - unfortunately the behaviour persisted.

I’ve logged out the details you requested (disabling the spawners and dropping in a single instance of the skeleton prefab to the scene):

Screenshot 2021-04-19 120548

The messages in your console are helpful. We now know that there is only one enemy in the scene, the speed value is constant, and the messages get logged into the console every x frames.

Did this single enemy move properly or did the behaviour persist?

If the latter, remove Time.deltaTime for testing purposes.

You could also log the value which you pass on to the Translate method into your console to see in which frame it significantly increases.

The enemies suddenly speed up on the 3rd or 4th tile. Also, some enemies seem to move forwards and then, for a brief moment, backwards before they move forwards again. Since they look the same, it is impossible to tell whether they are the same enemies or two different enemies. You could log the same messages which you used for the single enemy for the spawned enemies to see if something “interesting” happens in the console.

Privacy & Terms