Like this:-
if (Input.GetButtonDown(“Fire1”))
{
GameObject laser_R = Instantiate(LaserPrefab, LaserPos_R, Quaternion.identity) as GameObject;
laser_R.GetComponent().velocity = new Vector2(0, ProjectileSpeed);GameObject laser_L = Instantiate(LaserPrefab, LaserPos_L, Quaternion.identity) as GameObject; laser_L.GetComponent<Rigidbody2D>().velocity = new Vector2(0, ProjectileSpeed); Destroy(laser_L, 1.5f); Destroy(laser_R, 1.5f); } else if (Input.GetButton("Fire1") && Time.time>FiringPeriod) { GameObject laser_R = Instantiate(LaserPrefab, LaserPos_R, Quaternion.identity) as GameObject; laser_R.GetComponent<Rigidbody2D>().velocity = new Vector2(0, ProjectileSpeed); GameObject laser_L = Instantiate(LaserPrefab, LaserPos_L, Quaternion.identity) as GameObject; laser_L.GetComponent<Rigidbody2D>().velocity = new Vector2(0, ProjectileSpeed); Destroy(laser_L, 1.5f); Destroy(laser_R, 1.5f); }
The result is the same: