# Directional shooting/ enemies shooting

**URL:** <https://forum.makecode.com/t/directional-shooting-enemies-shooting/17469>\
**Category:** Help\
**Created:** [January 17, 2023, 5:19pm UTC](https://forum.makecode.com/t/directional-shooting-enemies-shooting/17469 "2023-01-17T17:19:27Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jacks0nian](https://avatars.discourse-cdn.com/v4/letter/j/6a8cbe/32.png) [@Jacks0nian](https://forum.makecode.com/u/Jacks0nian)\
**Post date:** [January 17, 2023, 5:19pm UTC](https://forum.makecode.com/t/directional-shooting-enemies-shooting/17469/1 "2023-01-17T17:19:27Z")

</div>

I’m trying to make a side to side halo game and I’m having trouble with a few things,  
First is how i make enemies shoot at me  
Second is how i make the gun shoot the direction I’m facing

---

<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:** [January 18, 2023, 1:11am UTC](https://forum.makecode.com/t/directional-shooting-enemies-shooting/17469/2 "2023-01-18T01:11:59Z")

</div>

If you use the Character animation extension, use a simple if else statement for the states. For enemies just compare the x and y values of the player and the enemy and fire a projectile based on the comparison.

You can check my Halo Local Multiplayer game for player direction.

---

<div class="post-metadata">

**Author:** ![Jacks0nian](https://avatars.discourse-cdn.com/v4/letter/j/6a8cbe/32.png) [@Jacks0nian](https://forum.makecode.com/u/Jacks0nian)\
**Post date:** [January 19, 2023, 4:14pm UTC](https://forum.makecode.com/t/directional-shooting-enemies-shooting/17469/3 "2023-01-19T16:14:46Z")

</div>

I tried the directional shooting but it’s still not working

---

<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:** [January 19, 2023, 11:26pm UTC](https://forum.makecode.com/t/directional-shooting-enemies-shooting/17469/4 "2023-01-19T23:26:11Z")

</div>

can i see the code? it might be in the projectile code. It needs to be set to the correct x and y velocity values. Y must be 0, and X is the speed you want it to be. Add a negative to it and it will change direction at the same speed. The states from the character animation just tell the game at what time to change direction.

---

<div class="post-metadata">

**Author:** ![Jacks0nian](https://avatars.discourse-cdn.com/v4/letter/j/6a8cbe/32.png) [@Jacks0nian](https://forum.makecode.com/u/Jacks0nian)\
**Post date:** [January 20, 2023, 5:25pm UTC](https://forum.makecode.com/t/directional-shooting-enemies-shooting/17469/5 "2023-01-20T17:25:20Z")

</div>

Sure heres the link [https://arcade.makecode.com/#editor](https://arcade.makecode.com/#editor)

---

<div class="post-metadata">

**Author:** ![KIKIvsIT](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kikivsit/32/10492_2.png) [@KIKIvsIT](https://forum.makecode.com/u/KIKIvsIT)\
**Post date:** [January 20, 2023, 5:27pm UTC](https://forum.makecode.com/t/directional-shooting-enemies-shooting/17469/6 "2023-01-20T17:27:20Z")

</div>

@Jacks0nian, can you go back into your project and click the share button to grab the share URL that looks more like this: [https://arcade.makecode.com/S07614-94936-04135-66963](https://arcade.makecode.com/S07614-94936-04135-66963)

The link from the address bar will just take people back to whatever game they had open last.

---

<div class="post-metadata">

**Author:** ![Jacks0nian](https://avatars.discourse-cdn.com/v4/letter/j/6a8cbe/32.png) [@Jacks0nian](https://forum.makecode.com/u/Jacks0nian)\
**Post date:** [January 20, 2023, 7:06pm UTC](https://forum.makecode.com/t/directional-shooting-enemies-shooting/17469/7 "2023-01-20T19:06:50Z")

</div>

Ok thanks

---

<div class="post-metadata">

**Author:** ![Jacks0nian](https://avatars.discourse-cdn.com/v4/letter/j/6a8cbe/32.png) [@Jacks0nian](https://forum.makecode.com/u/Jacks0nian)\
**Post date:** [January 20, 2023, 7:24pm UTC](https://forum.makecode.com/t/directional-shooting-enemies-shooting/17469/8 "2023-01-20T19:24:15Z")

</div>

Here’s the real link sorry [https://arcade.makecode.com/S61214-90222-42344-41153](https://arcade.makecode.com/S61214-90222-42344-41153)
