# Why I could not make player walking animation?

**URL:** https://forum.makecode.com/t/why-i-could-not-make-player-walking-animation/4968
**Category:** Help
**Created:** [December 12, 2020, 10:27am UTC](https://forum.makecode.com/t/why-i-could-not-make-player-walking-animation/4968 "2020-12-12T10:27:57Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![TomX](https://avatars.discourse-cdn.com/v4/letter/t/97f17d/32.png) [@TomX](https://forum.makecode.com/u/TomX)
#### Post date: [December 12, 2020, 10:27am UTC](https://forum.makecode.com/t/why-i-could-not-make-player-walking-animation/4968/1 "2020-12-12T10:27:57Z")

</div>

Hello, I tried to make my player sprite walking animation by display 2 different pictures but it always fails, anyone gives me some tips or it is a bug? It‘s by check the remainder of x/2, here is the code:

 ![2](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/4/4a26177d85f466da102d38f87e8366949c2299f5.jpeg) ![11](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/3/31d557cea56f6add86f48c66c283d1c802fdca6e.jpeg)

thanks!

---

<div class="post-metadata">

### Author: ![jwunderl](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jwunderl/32/5308_2.png) [@jwunderl](https://forum.makecode.com/u/jwunderl)
#### Post date: [December 12, 2020, 10:40am UTC](https://forum.makecode.com/t/why-i-could-not-make-player-walking-animation/4968/2 "2020-12-12T10:40:45Z")

</div>

The issue here is that sprite.x isn’t an integer but just a normal number; 3.5 is a valid x position, and remainder of 3.5 % 2 is 1.5. (This is mainly necessary to maintain accurate movement across different frame rates / even with low speeds). You’re _almost_ never going to hit the == 0 case if you aren’t explicitly setting x (e.g. using the move sprite block or velocity will leave remainders at times).

Probably easiest fix is to use a `truncate` block around kid x (note also that remainder can br negative, but that should be fine with the truncate in the right spot). That block is in the same dropdown as round, and just cuts off the fractional portion of a number.

It might also be worth looking at the animations extension for setting up simple animations (with help in the image editor to preview / show previous frames). Richard also wrote the [https://github.com/riknoll/character-animations](https://github.com/riknoll/character-animations) extension, though thats a bit newer / more complex - its super useful for having full animation sets for different directions / etc.

---

<div class="post-metadata">

### Author: ![TomX](https://avatars.discourse-cdn.com/v4/letter/t/97f17d/32.png) [@TomX](https://forum.makecode.com/u/TomX)
#### Post date: [December 13, 2020, 7:08am UTC](https://forum.makecode.com/t/why-i-could-not-make-player-walking-animation/4968/3 "2020-12-13T07:08:31Z")

</div>

Thank you so much for your reply! I tried `truncate` block it works quite well!  
However, the [https://github.com/riknoll/character-animations](https://github.com/riknoll/character-animations) extension seems had been removed?

BTW, I use the remainder trick by learning from this official video:

[![](https://img.youtube.com/vi/8DhGcCPfOU4/maxresdefault.jpg "How to Make a Platformer Game [Part 2: Animations, AI, collision & spawning]") ](https://www.youtube.com/watch?v=8DhGcCPfOU4)

notice: at 23:02 begins to make the cat walking animation without truncate block.  
Should we consider it as a bug or version difference maybe?

 ![1111](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/a/a272f8db838ee38f8aa41aefe0ae8051701fc1c5.jpeg)

thanks again！

---

<div class="post-metadata">

### Author: ![jwunderl](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jwunderl/32/5308_2.png) [@jwunderl](https://forum.makecode.com/u/jwunderl)
#### Post date: [December 13, 2020, 7:15am UTC](https://forum.makecode.com/t/why-i-could-not-make-player-walking-animation/4968/4 "2020-12-13T07:15:39Z")

</div>

Ahhh, that was a bug in an older version of arcade almost a year ago that caused the values to be stored as floats but read out as ints - this behavior broke a number of things, e.g. having `change mysprite x by .1` would actually move the sprite slightly to the left half the time. @darzu maybe we can add a comment on the video noting this behavioral difference?

Thanks for pointing that out!

Also, it looks like the extension is still there to me? Is it not showing up when you paste the github url into the extensions dialog?

---

<div class="post-metadata">

### Author: ![TomX](https://avatars.discourse-cdn.com/v4/letter/t/97f17d/32.png) [@TomX](https://forum.makecode.com/u/TomX)
#### Post date: [December 13, 2020, 5:11pm UTC](https://forum.makecode.com/t/why-i-could-not-make-player-walking-animation/4968/5 "2020-12-13T17:11:37Z")

</div>

Great, understood!  
the extension appears by paste the Github url on the extensions dialog but I didn’t find a character animation option on the toolbar. Does it just add some like walking animation blocks in Animation tools?  
 ![222](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/6/64c66ee0e835b9bfd1bf404962da2794975a6714.jpeg)

 ![333](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/3/3731e31dcfee268bb1e783c2ae45c3b89d4cad33.jpeg)  
I am new and not quite familiar with the blocks  
thanks

---

<div class="post-metadata">

### Author: ![jwunderl](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jwunderl/32/5308_2.png) [@jwunderl](https://forum.makecode.com/u/jwunderl)
#### Post date: [December 13, 2020, 5:59pm UTC](https://forum.makecode.com/t/why-i-could-not-make-player-walking-animation/4968/6 "2020-12-13T17:59:36Z")

</div>

It should be the category right above ‘advanced’ in that acreenshot, ‘Character’:

![SmartSelect_20201213-095707_Chrome](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/9/910bcc85a1567e3988b7e18b98f40481461a3199.jpeg)

---

<div class="post-metadata">

### Author: ![darzu](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/darzu/32/1882_2.png) [@darzu](https://forum.makecode.com/u/darzu)
#### Post date: [December 14, 2020, 6:41pm UTC](https://forum.makecode.com/t/why-i-could-not-make-player-walking-animation/4968/7 "2020-12-14T18:41:58Z")

</div>

Yes thanks for pointing this out. I’ll post a comment on the video. It was always a little bit odd, so I’ll try to find a better way to do this.
