So I wrote this shooting code so when the player pressed left mouse button a bullet will fire. However, a bullets if being fired every frame even when i didn’t press fire. Help!!
Shooting Code:
using UnityEngine;
using System.Collections;
public class PlayerShooting : MonoBehaviour
{
GameObject prefab;
// Use this for initialization
void Start()
{
prefab = Resources.Load("Bullet") as GameObject;
}
void FixedUpdate()
{
if (Input.GetMouseButtonDown(0)) ;
{
GameObject Bullet = Instantiate(prefab) as GameObject;
Bullet.transform.position = transform.position + Camera.main.transform.forward * 5;
Rigidbody rb = Bullet.GetComponent<Rigidbody>();
rb.velocity = Camera.main.transform.forward * 100;
}
}
}
`