Hello, I am making a first person shooter and I’m making a firing gun. However, with all the scripts I try the gun constantly fires in only one direction, on the right side of the x axis. Heres the script I’m using now:
var shootForce : float;
var bulletPrefab : Transform;
var myMuzzle : Transform;
function Update ()
{
if(Input.GetButtonDown("Fire1"))
{
var bullet = Instantiate(bulletPrefab, myMuzzle.transform.position, Quaternion.identity);
bullet.rigidbody.AddForce(transform.forward * shootForce, ForceMode.Impulse);
}
}
Just for extra information, the muzzle is an empty game object which is a child of the gun, it’s what spawns the bullets. Could someone help me out. Thank you