# Enemy Knockback Clip

**URL:** https://forum.makecode.com/t/enemy-knockback-clip/10957
**Category:** Help
**Created:** [November 19, 2021, 5:42am UTC](https://forum.makecode.com/t/enemy-knockback-clip/10957 "2021-11-19T05:42:27Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![personalnote](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/personalnote/32/31359_2.png) [@personalnote](https://forum.makecode.com/u/personalnote)
#### Post date: [November 19, 2021, 5:42am UTC](https://forum.makecode.com/t/enemy-knockback-clip/10957/1 "2021-11-19T05:42:27Z")

</div>

> **[Requiem Final](https://arcade.makecode.com/10507-28706-36312-01834)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

When the enemies hit you, you get pushed back depending on where you’re facing. But when you get pushed against a wall, you clip through the ground, where i’ve set a reset button (Im gonna change it cause it’s too time-consuming).

---

<div class="post-metadata">

### Author: ![SoftTalker](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/softtalker/32/10776_2.png) [@SoftTalker](https://forum.makecode.com/u/SoftTalker)
#### Post date: [November 19, 2021, 5:11pm UTC](https://forum.makecode.com/t/enemy-knockback-clip/10957/2 "2021-11-19T17:11:43Z")

</div>

nice job

---

<div class="post-metadata">

### Author: ![personalnote](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/personalnote/32/31359_2.png) [@personalnote](https://forum.makecode.com/u/personalnote)
#### Post date: [November 20, 2021, 12:47am UTC](https://forum.makecode.com/t/enemy-knockback-clip/10957/3 "2021-11-20T00:47:09Z")

</div>

Hold on, sorry I think you misinterpreted me. I meant that as a bad thing. You clipping through the ground wasn’t meant to happen. I would just want the enemies to just hit you back, and if you were hit against a wall, you’d get basically cornered.

---

<div class="post-metadata">

### Author: ![SoftTalker](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/softtalker/32/10776_2.png) [@SoftTalker](https://forum.makecode.com/u/SoftTalker)
#### Post date: [November 22, 2021, 4:19pm UTC](https://forum.makecode.com/t/enemy-knockback-clip/10957/4 "2021-11-22T16:19:30Z")

</div>

i meant the game concept

---

<div class="post-metadata">

### Author: ![TheJaky](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/thejaky/32/5711_2.png) [@TheJaky](https://forum.makecode.com/u/TheJaky)
#### Post date: [November 22, 2021, 4:25pm UTC](https://forum.makecode.com/t/enemy-knockback-clip/10957/5 "2021-11-22T16:25:23Z")

</div>

Sorry about that glitch, I love the sprites, very detailed.

---

<div class="post-metadata">

### Author: ![personalnote](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/personalnote/32/31359_2.png) [@personalnote](https://forum.makecode.com/u/personalnote)
#### Post date: [November 23, 2021, 12:29am UTC](https://forum.makecode.com/t/enemy-knockback-clip/10957/6 "2021-11-23T00:29:06Z")

</div>

sorry, i misunderstood you

---

<div class="post-metadata">

### Author: ![personalnote](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/personalnote/32/31359_2.png) [@personalnote](https://forum.makecode.com/u/personalnote)
#### Post date: [November 23, 2021, 12:29am UTC](https://forum.makecode.com/t/enemy-knockback-clip/10957/7 "2021-11-23T00:29:07Z")

</div>

thank you

---

<div class="post-metadata">

### Author: ![shakao](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/shakao/32/113_2.png) [@shakao](https://forum.makecode.com/u/shakao)
#### Post date: [November 23, 2021, 12:43am UTC](https://forum.makecode.com/t/enemy-knockback-clip/10957/8 "2021-11-23T00:43:27Z")

</div>

Wow, awesome game! I love the character art and animations, and the title screen looks incredible. And yeah, the clipping is because we don’t check for walls if you explicitly change the x and y of a sprite by a large amount (we will automatically “bump” the sprite away from the wall if you’re only overlapping by 2 or 3 pixels). To avoid this, you could briefly give the sprite an x and y velocity to “push” it back:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/1/16114a680f3ab0cb918dde3160c33da6c11a683e.png)

This code disables the player controls, pushes the sprite, then after a brief pause, re-enables the controls (otherwise a player holding down the d-pad might override the knockback). You might need to mess around with the numbers a bit, but using the velocity instead of setting the position should allow for correct wall collisions!

---

<div class="post-metadata">

### Author: ![personalnote](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/personalnote/32/31359_2.png) [@personalnote](https://forum.makecode.com/u/personalnote)
#### Post date: [November 23, 2021, 5:03pm UTC](https://forum.makecode.com/t/enemy-knockback-clip/10957/9 "2021-11-23T17:03:40Z")

</div>

thank you so much!
