Hello I am working through the shooting shots tutorial for the space shooter and came across an issue with the shots turning into a stream instead of just one shot per click I have checked the code for the bolt and for the player and all looks good. May not be seeing the issue can anyone help me to find the issue here please?
here is the player code I have so far if that helps thank you for the help in advance
private Rigidbody rb;
public float Speed;
public float Tilt;
public Boundary boundary;
public GameObject Shot;
public Transform ShotSpawn;
public float FireRate;
private float NextFire;
void Start()
{
rb = GetComponent<Rigidbody>();
}
void Update()
{
if (Input.GetButton("Fire1") && Time.time > NextFire)
NextFire = Time.time * FireRate;
Instantiate(Shot, ShotSpawn.position, ShotSpawn.rotation);
}
void FixedUpdate()
{
float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
rb.AddForce (movement*Speed) ;
rb.position = new Vector3
(
Mathf.Clamp (rb.position.x,boundary.xMin,boundary.xMax),
0.0f,
Mathf.Clamp (rb.position.z,boundary.zMin,boundary.zMax)
)
;
rb.rotation = Quaternion.Euler(0.0f, 0.0f, movement.x * -Tilt);
}
}