Guns shoot backwards

I'm making an FPS and I got all the guns in, but for some strange reason, all the guns shoot backwards, when I fire a rocket, it comes out from behind, same with all the other weapons, can someone please help me?

Edit: Alright, I got the gun to shoot normally, and I got the Rocket to shoot out of the Rocket Launcher in the front, but the rocket comes out backwards, with the head facing you, anyone know how to fix that?

Rocket:

var explosion : GameObject; var timeOut = 3.0;

function Start () { Invoke("Kill", timeOut); }

function OnCollisionEnter (collision : Collision) { var contact : ContactPoint = collision.contacts[0]; var rotation = Quaternion.FromToRotation(Vector3.up, contact.normal); Instantiate (explosion, contact.point, rotation);

Kill ();    

}

function Kill () { var emitter : ParticleEmitter= GetComponentInChildren(ParticleEmitter); if (emitter) emitter.emit = false;

transform.DetachChildren();

Destroy(gameObject);

}

@script RequireComponent (Rigidbody)

Rocket Launcher:

var projectile : Rigidbody; var initialSpeed = 20.0; var reloadTime = 0.5; var ammoCount = 20; private var lastShot = -10.0;

function Fire () { if (Time.time > reloadTime + lastShot && ammoCount > 0) { var instantiatedProjectile : Rigidbody = Instantiate (projectile, transform.position, transform.rotation);

    instantiatedProjectile.velocity = transform.TransformDirection(-Vector3 (0, 0, initialSpeed));

    Physics.IgnoreCollision(instantiatedProjectile.collider, transform.root.collider);

    lastShot = Time.time;
    ammoCount--;
}

}

Can you post your Fire script? It would be helpful to see it.

Post both scripts in a edit. Your using instantiate for your rocket right? If you are, there should be a rotation value at the end. Set it to transform.rotation

1 Answer

1

When you shoot, the script probable translate it with a word like, up, forward, or right (I think), just add a negative sign (-) before that whole statement...

IE: transform.Translate(-Vector3.forward * Time.deltaTime);