# Help, with projectile motion in game

**URL:** <https://discourse.processing.org/t/help-with-projectile-motion-in-game/11760>\
**Category:** Coding Questions\
**Created:** [June 1, 2019, 5:21pm UTC](https://discourse.processing.org/t/help-with-projectile-motion-in-game/11760 "2019-06-01T17:21:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [June 1, 2019, 5:21pm UTC](https://discourse.processing.org/t/help-with-projectile-motion-in-game/11760/1 "2019-06-01T17:21:50Z")

</div>

I’m making a game with a digger, at the moment I’ve added a fire mechanism which shoots little projectile, this was just a test to see if I could code it. It works however I do not understand how to adjust for the vehicle movement. Ie if the vehicle is moving is moving forward, how can I make the bullets account for the change in speed.

thanks guys.

[https://editor.p5js.org/paulgoux/sketches/0lem09rp-](https://editor.p5js.org/paulgoux/sketches/0lem09rp-)

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [June 1, 2019, 5:57pm UTC](https://discourse.processing.org/t/help-with-projectile-motion-in-game/11760/2 "2019-06-01T17:57:11Z")

</div>

Just add the tank speed to the bullet speed (set the initial speed of the bullet to that of the tank)

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [June 1, 2019, 6:50pm UTC](https://discourse.processing.org/t/help-with-projectile-motion-in-game/11760/3 "2019-06-01T18:50:25Z")

</div>

Thats what I initially thought but however I try it it doesn’t seem to work, and simply sends the vehicle speeds past the projectiles.

The only solution I found that worked was to increase the projectile acceleration.

Sketch updated

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [June 1, 2019, 7:16pm UTC](https://discourse.processing.org/t/help-with-projectile-motion-in-game/11760/4 "2019-06-01T19:16:56Z")

</div>

Fixed, completely forgot, that the x component of the tank velocity was calculated using its y velocity.

Code rectified, with your suggestion Chrisir, thanks.
