I have a Javascript that is meant to make a gun fire but does not make the bullets fly forwards, they just drop. can anyone help?
Script:
#pragma strict
var projectile : GameObject;
var fireRate : float;
private var nextSpawnTime : float;
function Start () {
nextSpawnTime = Time.time + fireRate;
}
function Update () {
// left-click was pressed, launch a projectile
if ((Input.GetButtonDown(“Fire1”)) && (Time.time > nextSpawnTime)) {
// Instantiate the projectile at the position and rotation of this transform
Instantiate(projectile, transform.position, Quaternion.identity);
nextSpawnTime = Time.time + fireRate;
}
}