bullet instantiation not quite working (video linked)

ABove you’ll see my probelm, i’ve been creating a 2d scrolling shooter for some time, however I’ve come to a problem with my bullets, and how they’re instantiated.

When runnning and holding down space they show no signs of movement, and turn into a spaced out string of bullets, needless to say this doesn’t work, and I’m all out of ideas…

			/*if(Input.GetKey("space")){
		var tempBullet: Rigidbody;
		tempBullet = Instantiate(bullet, transform.position, transform.rotation);*/

The above is my commented out code for instantiating single bullets, but realising i need to hold to fire, that quickly got negated.

Below is my current code, where things have clearly nto quite qorked :frowning:

		if (Input.GetKey ("space") && Time.time > nextFire) {
		nextFire = Time.time - fireRate;
		var clone = Instantiate (bullet, transform.position, Quaternion.Euler(0, 0, 0));
		var tempShotsound = Instantiate(shot, transform.position, transform.rotation);
		}

Any ideas are greatly appreciated!

hmm… I’m very inexperienced, too, so I can’t really tell… but when I look at this I’m confused about the

Time.time > nextFire and nextFire = Time.time - fireRate;

should it not be

Time.time < nextFire and nextFire = Time.time + fireRate;?

Time.time is the Time-since-start-of-game, so it becomes bigger each millisecond.

You take Time.time and subtract something.

Next frame starts and in the meantime Time.time get’s bigger.

and now you ask ‘is the new-and-bigger-Time.time greater-than the old-and-subtracted-Time.time?’

Of course it it.

As is, I think the if-statement returns ever-true when space is pressed. So you are instantiating a shot each frame which all move at the same speed…

Greetz, Ky.

It actually looks correct to me, but it looks like your bullets are really very fast so they leave the visible area quickly. Have you tried playing around with the speed of the bullets and your other values?