Bullet firing "stood up" and not at the correct rotation.

Hey the shooting script I am using has a little problem. The problem is when I fire the bullet from the spawn point, it fires vertical despite the fact the bullet prefab is facing the correct way. Basically the bullet is coming out of the barrel as though it is stood up and not facing forward, I can’t see what I’m doing wrong. Is it anything to do with the rigidbody or am I missing something in this:

var bulletPrefab:Transform;
var shotDelay = 2;
     
         function Start () {

    while (true) {
        while (!Input.GetButtonDown("Jump")) yield;
       bullet = Instantiate(bulletPrefab, GameObject.Find("SpawnPoint").transform.position, transform.rotation);
         bullet.rigidbody.AddForce(bullet.transform.forward * 5000);
        yield WaitForSeconds(shotDelay);
    }
}

Any help is appreciated :slight_smile: If you need anymore information feel free to ask.

As phodges says, it’s an inconsistant orientation problem.

In Unity, forward is officially the blue Z arrow (right is the red X arrow, up is the green Y arrow.) This means that your line AddForce(bullet.forward); pushes the bullet along it’s current blue arrow. I’m going to guess, if you drag the a bullet into the scene, that the bullet’s blue forward arrow is really pointing up.

One easy solution is to fire the bullet whichever way it thinks is forward. If the red arrow is pointing to the tip of the bullet, the tip is officially “bullet right” so use AddForce(bullet.rght);

That can be confusing (since other bullets may have to fire down or left.) Most people force everything so that forward-looking (like the bullet tip) really is forward, using childing. The “bullet” is a parent with everything except the model, with the bullet model childed. That allows you to spin the bullet so it’s tip and the parent blue arrow line up. I’m going to guess your gun has the same issue – the barrel probably faces the same “wrong” way as the bullet.