# Sprite animation missing cells

**URL:** <https://forum.babylonjs.com/t/sprite-animation-missing-cells/35498>\
**Category:** Questions\
**Created:** [November 8, 2022, 9:02am UTC](https://forum.babylonjs.com/t/sprite-animation-missing-cells/35498 "2022-11-08T09:02:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jinto\_jose](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jinto_jose/32/28000_2.png) [@jinto\_jose](https://forum.babylonjs.com/u/jinto_jose)\
**Post date:** [November 8, 2022, 9:02am UTC](https://forum.babylonjs.com/t/sprite-animation-missing-cells/35498/1 "2022-11-08T09:02:15Z")

</div>

I am using a sprite png with 6 poses (3 in one row). Height and width units are not same. So, I added width and height in SpriteManager.

And, the animation is running fine for the first 3 cells. Second row cells are not taken correctly. Because of that, animation is missing steps.

How do I fix this animation?

Playground: [https://playground.babylonjs.com/#DG9MVV#4](https://playground.babylonjs.com/#DG9MVV#4)  
Repo: [GitHub - jintoppy/babylonjs-character-walking](https://github.com/jintoppy/babylonjs-character-walking)

Sidenote: What exactly is capacity when creating a SpriteManager? I gave 6 assuming that, it is the total number of cells in the sprite.

Thanks.

---

<div class="post-metadata">

**Author:** ![mawa](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mawa/32/12384_2.png) [@mawa](https://forum.babylonjs.com/u/mawa)\
**Post date:** [November 8, 2022, 10:00am UTC](https://forum.babylonjs.com/t/sprite-animation-missing-cells/35498/2 "2022-11-08T10:00:45Z")

</div>

Looks like the width of your image does not match your cells. Image size is 559px X 447px.  
Your declared cells size is 180 x 223 px. And then, you should avoid half-pixels.  
So, if your cell size really is 180 x 223, then your image should be **540 x 446 px.**

Edit: Oh and btw, a warm welcome to the Community. 😃

Fixed version:

> **[Babylon.js Playground](https://playground.babylonjs.com/#DG9MVV%237)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

Note: if you start with 0 and have 6 cells in total, then your end cell number is 5 (not 6).  
Also, the alignment in this twisted version of your image is not accurate. You will have to edit the spritesheet image.

---

<div class="post-metadata">

**Author:** ![mawa](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mawa/32/12384_2.png) [@mawa](https://forum.babylonjs.com/u/mawa)\
**Post date:** [November 8, 2022, 10:23am UTC](https://forum.babylonjs.com/t/sprite-animation-missing-cells/35498/3 "2022-11-08T10:23:57Z")

</div>

> [@jinto\_jose](#):
>
> capacity when creating a SpriteManager

…and you are right. It is the number of cells, in case of an animation. But it’s also the number of single sprites that can be generated by the manager. Up to several thousands.

---

<div class="post-metadata">

**Author:** ![jinto\_jose](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jinto_jose/32/28000_2.png) [@jinto\_jose](https://forum.babylonjs.com/u/jinto_jose)\
**Post date:** [November 8, 2022, 10:35am UTC](https://forum.babylonjs.com/t/sprite-animation-missing-cells/35498/4 "2022-11-08T10:35:47Z")

</div>

Thank you so much for the detailed reply. 🙂

And, thank you for the welcome. I thought to check back BabylonJS ( I tried few times earlier and couldn’t really do much ), and absolutely loved the ACE editor. 😍 😍
