# Weird homing bug

**URL:** <https://forum.makecode.com/t/weird-homing-bug/36261>\
**Category:** Help\
**Tags:** game\
**Created:** [April 30, 2025, 3:08pm UTC](https://forum.makecode.com/t/weird-homing-bug/36261 "2025-04-30T15:08:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stickman4269](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/stickman4269/32/23582_2.png) [@Stickman4269](https://forum.makecode.com/u/Stickman4269)\
**Post date:** [April 30, 2025, 3:08pm UTC](https://forum.makecode.com/t/weird-homing-bug/36261/1 "2025-04-30T15:08:44Z")

</div>

I have a tbs 2-player game with a unit (the drone) that is supposed to have weak homing on its attacks which works fine when shooting left to right but when the shot is going right to left it turns around and moves randomly until it exits the homing range. Can anyone help?  
The homing code:

 ![IMG_0221](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/7/a/7aaa4a650d5e9d348d421196479ab91803c5cc04.jpeg)  
The full game:

> **[Nexus Assault 2 - NTV](https://arcade.makecode.com/S90500-87104-28463-73408)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<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:** [April 30, 2025, 5:25pm UTC](https://forum.makecode.com/t/weird-homing-bug/36261/2 "2025-04-30T17:25:36Z")

</div>

Can’t you just use the follow block or something?

---

<div class="post-metadata">

**Author:** ![Stickman4269](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/stickman4269/32/23582_2.png) [@Stickman4269](https://forum.makecode.com/u/Stickman4269)\
**Post date:** [April 30, 2025, 10:27pm UTC](https://forum.makecode.com/t/weird-homing-bug/36261/4 "2025-04-30T22:27:59Z")

</div>

No because I want the bullets to have a chance of missing if they turn too slowly

---

<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:** [May 1, 2025, 3:34am UTC](https://forum.makecode.com/t/weird-homing-bug/36261/5 "2025-05-01T03:34:06Z")

</div>

That’s exactly what I was thinking. Also what’s all those “ + convert ( 360 ) degrees to radians” for? Doesn’t that do literally nothing? Anyways there’s a chance that’s your problem, but I’m too lazy to actually think through the implications of that, so it might be the problem. It might be random because shooting right to left doesn’t cross a 360 → 0 wrap around? Like maybe somehow that wrap around is helping this code work, but when you go the other way the code is all messed up? Idk.

I usually answer every help question I see, but I’m a bit short on time atm so I’ll revisit this sometime later if you haven’t solved it by then.

---

<div class="post-metadata">

**Author:** ![Stickman4269](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/stickman4269/32/23582_2.png) [@Stickman4269](https://forum.makecode.com/u/Stickman4269)\
**Post date:** [May 1, 2025, 3:32pm UTC](https://forum.makecode.com/t/weird-homing-bug/36261/6 "2025-05-01T15:32:36Z")

</div>

> Also what’s all those “ + convert ( 360 ) degrees to radians” for? Doesn’t that do literally nothing?

I put those there just to make sure that there wouldn’t be any positive + negative = bug. The bug was happening before I added those.
