# Unity Gun Problems JS

**URL:** https://discussions.unity.com/t/unity-gun-problems-js/601093
**Category:** Scripting
**Tags:** Scripting
**Created:** [October 11, 2015, 5:40pm UTC](https://discussions.unity.com/t/unity-gun-problems-js/601093 "2015-10-11T17:40:07Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Fireking883](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/fireking883/32/313615_2.png) [@Fireking883](https://discussions.unity.com/u/Fireking883)
#### Post date: [October 11, 2015, 5:40pm UTC](https://discussions.unity.com/t/unity-gun-problems-js/601093/1 "2015-10-11T17:40:07Z")

</div>

I have tried looking all over the internet for a fix and have spent a long time trying to fix the problem myself, so before you say look it up, I have. My problem is that the bullet I instantiate is not going forward, but to the right or at a 45 degree angle up from where it is supposed to shoot from. I want the bullet to shoot straight forward, but I cannot figure out how to do this. I have created an empty gameobject at the end of my gun and instantiate from there. Here is my script:

```javascript
#pragma strict
var Barrel : Transform;
var BarrelPos : Transform;
var Bullet1 : GameObject;
function Update () {
    if (Input.GetKey(KeyCode.LeftArrow)){
          Barrel.Rotate(Vector3.back, Space.Self);
    }
    if (Input.GetKey(KeyCode.RightArrow)){
         Barrel.Rotate(Vector3.forward, Space.Self);
    }
    if (Input.GetKeyDown(KeyCode.Space)){
        var Bullet = Instantiate(Bullet1, BarrelPos.position, BarrelPos.rotation) as GameObject;
        Bullet.GetComponent.<Rigidbody>().AddForce(BarrelPos.position * 1000);
    }
}

```

Thanks in advance for help!

---

<div class="post-metadata">

### Author: ![Fireking883](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/fireking883/32/313615_2.png) [@Fireking883](https://discussions.unity.com/u/Fireking883)
#### Post date: [October 11, 2015, 5:45pm UTC](https://discussions.unity.com/t/unity-gun-problems-js/601093/2 "2015-10-11T17:45:22Z")

</div>

I have seemed to of fixed it by locking the y position on the bullet, so no need to answer.
