# Shooting Offset

**URL:** https://forum.kirupa.com/t/shooting-offset/319470
**Category:** flash
**Created:** [February 21, 2011, 11:40pm UTC](https://forum.kirupa.com/t/shooting-offset/319470 "2011-02-21T23:40:30Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![DanDaMan](https://avatars.discourse-cdn.com/v4/letter/d/b19c9b/32.png) [@DanDaMan](https://forum.kirupa.com/u/DanDaMan)
#### Post date: [February 21, 2011, 11:40pm UTC](https://forum.kirupa.com/t/shooting-offset/319470/1 "2011-02-21T23:40:30Z")

</div>

Hey 🙂 I’m using this code to have an object called mc create a bullet and shoot it in the direction it is facing:

```php
angle=mc.rotation*Math.PI/180;
x=mc.x+Math.cos(angle)*barrelLength;
y=mc.y+Math.sin(angle)*barrelLength;
speedX=Math.cos(angle)*20;
speedY=Math.sin(angle)*20;
rotation=angle/Math.PI*180;

```

Pretty simple. But this only works if the point I want to create the bullet is has the same y value as the bullet creator (mc). Say the bullet creator is holding the gun off to it’s side - for example, 10 pixels below mc’s center when it’s pointing to the right. I need the point in which the bullet starts off to be 10 pixels from where it is now. And, of course, the x and y coordinates of this point will change with the rotation of mc. I’m not very good at explaining it so let me know if you need clarification. Thanks for your help 😃
