# Spawned enemy movement

**URL:** <https://forum.makecode.com/t/spawned-enemy-movement/12063>\
**Category:** Help\
**Created:** [February 7, 2022, 7:57pm UTC](https://forum.makecode.com/t/spawned-enemy-movement/12063 "2022-02-07T19:57:02Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![G-type](https://avatars.discourse-cdn.com/v4/letter/g/f4b2a3/32.png) [@G-type](https://forum.makecode.com/u/G-type)\
**Post date:** [February 7, 2022, 7:57pm UTC](https://forum.makecode.com/t/spawned-enemy-movement/12063/1 "2022-02-07T19:57:02Z")

</div>

I’ve randomly generated 8 enemies, but only 1 is moving and I’m not sure why.

also, there is a random sprite for my fireball projectile in the upper left corner and I don’t know how it got there.

 ![Screen Shot 2022-02-07 at 2.09.51 PM](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/6/61f23939c8873e6ea9de9cd26b1206fa9ddde0ec.png)

---

<div class="post-metadata">

**Author:** ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)\
**Post date:** [February 7, 2022, 7:59pm UTC](https://forum.makecode.com/t/spawned-enemy-movement/12063/2 "2022-02-07T19:59:10Z")

</div>

You’re using the `myEnemy` variable in your for-loop, which only points to the last created bug. Try dragging out the `value` variable from the for-loop instead

---

<div class="post-metadata">

**Author:** ![G-type](https://avatars.discourse-cdn.com/v4/letter/g/f4b2a3/32.png) [@G-type](https://forum.makecode.com/u/G-type)\
**Post date:** [February 7, 2022, 10:18pm UTC](https://forum.makecode.com/t/spawned-enemy-movement/12063/3 "2022-02-07T22:18:25Z")

</div>

thanks! That fixed it. any ideas about that random fireball sprite sitting in the corner?

---

<div class="post-metadata">

**Author:** ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)\
**Post date:** [February 7, 2022, 10:29pm UTC](https://forum.makecode.com/t/spawned-enemy-movement/12063/4 "2022-02-07T22:29:21Z")

</div>

@G-type what’s the fireball supposed to do? Also, can you share your code? Here’s a gif showing how to do it:

![2022-01-11 10.49.58](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/0/0ac06b4feb9e3db866e8b677436c59a9b1f515e3.gif)

---

<div class="post-metadata">

**Author:** ![LostPineappleGames](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/lostpineapplegames/32/19789_2.png) [@LostPineappleGames](https://forum.makecode.com/u/LostPineappleGames)\
**Post date:** [February 21, 2025, 7:38pm UTC](https://forum.makecode.com/t/spawned-enemy-movement/12063/5 "2025-02-21T19:38:12Z")

</div>

I have a similar question about using the set value to kind player

 ![Screenshot 2025-02-21 at 07.33.54](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/c/7/c7d0566660b85b9ececaa6924ebe931c2c86de91.png)

---

<div class="post-metadata">

**Author:** ![redSprite](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/redsprite/32/34262_2.png) [@redSprite](https://forum.makecode.com/u/redSprite)\
**Post date:** [February 23, 2025, 5:40am UTC](https://forum.makecode.com/t/spawned-enemy-movement/12063/6 "2025-02-23T05:40:50Z")

</div>

That is because you’re using the “value” variable on a block input area which requires a sprite-type variable to function properly. The “value” variable is defined as a kind-type variable.

**My suggestion?**

Rework the Enemy Spawning System, make multiple on-element blocks in which each block has it’s own array of “tile” locations so it can spawn enemies in which you can define the type.

I’m pretty sure you don’t really know what I mean, I can make a simulation if you want.

---

<div class="post-metadata">

**Author:** ![WoofWoof](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/woofwoof/32/32523_2.png) [@WoofWoof](https://forum.makecode.com/u/WoofWoof)\
**Post date:** [February 23, 2025, 5:40am UTC](https://forum.makecode.com/t/spawned-enemy-movement/12063/7 "2025-02-23T05:40:57Z")

</div>

That block assumes “value” is a sprite, not a variable holding a sprite type, so you can only put sprites in that block. If you want to do what you are trying to do, you would have to use the small block at the bottom of the “Lifecycle” section in the Sprites tab, the one under the “array of sprites of kind (player)” block. You would use it inside a “set [variable] to ()” block, kinda like this:  
set [value] to ( ([player]) )

Hope this helps! Sorry for the weird block explanations, I’m too lazy to grab screenshots of everything
