# Picking up projectile sprite and then using it

**URL:** <https://forum.makecode.com/t/picking-up-projectile-sprite-and-then-using-it/13927>\
**Category:** Arcade\
**Tags:** game\
**Created:** [June 3, 2022, 3:03pm UTC](https://forum.makecode.com/t/picking-up-projectile-sprite-and-then-using-it/13927 "2022-06-03T15:03:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gumtowgames](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/gumtowgames/32/6379_2.png) [@gumtowgames](https://forum.makecode.com/u/gumtowgames)\
**Post date:** [June 3, 2022, 3:03pm UTC](https://forum.makecode.com/t/picking-up-projectile-sprite-and-then-using-it/13927/1 "2022-06-03T15:03:21Z")

</div>

I have a student who’s wants her player in her game to “grab” a weapon that’s in the level, and only once it is overlapped be able to fire the projectile using A button.

I certainly know how to get a projectile to come from the player, but can’t seem to figure out how to get a projectile to activate only once a sprite has been overlapped.

Thanks for the help!

---

<div class="post-metadata">

**Author:** ![Sarge](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/sarge/32/19590_2.png) [@Sarge](https://forum.makecode.com/u/Sarge)\
**Post date:** [June 6, 2022, 5:19pm UTC](https://forum.makecode.com/t/picking-up-projectile-sprite-and-then-using-it/13927/2 "2022-06-06T17:19:36Z")

</div>

Here I made a little example of this with comments in the code so you can understand what is going on:

> **[example](https://arcade.makecode.com/32498-97544-78218-62225)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

hope this helps!

---

<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:** [June 6, 2022, 5:19pm UTC](https://forum.makecode.com/t/picking-up-projectile-sprite-and-then-using-it/13927/3 "2022-06-06T17:19:39Z")

</div>

Very easy to implement.

Do these lines of code:

```auto
On SpriteType Player overlap with OtherSpriteType (Gunsprite Type):
- Destroy OtherSpriteType
- Set picked_up_gun variable to true

```

```auto
On Start:
- Set picked_up_gun variable to false

```

```auto
On press A:
- If picked_up_gun variable = true then:
  - Set projectile [image], vx, vy

```

Let me know if anything goes wrong. I did this from the back of my head.

---

<div class="post-metadata">

**Author:** ![gumtowgames](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/gumtowgames/32/6379_2.png) [@gumtowgames](https://forum.makecode.com/u/gumtowgames)\
**Post date:** [June 8, 2022, 4:21pm UTC](https://forum.makecode.com/t/picking-up-projectile-sprite-and-then-using-it/13927/4 "2022-06-08T16:21:35Z")

</div>

Thank you both! That’s very helpful and solved the problem.
