How do I set random fire rates?

Just started using Construct 2? Post your questions here

Post » Mon Sep 01, 2014 9:09 pm

This one is kind of embarrassing because I'm certain I should be able to do it myself by now but I'm finding it difficult. All I want to do is set each instance of an enemy to fire when certain conditions are met (line of sight to player, is on-screen, is visible etc) at a randomly determined rate and have this rate change after each shot. Currently, it seems I can't do this without all instances firing at the same rate, even when I try setting that rate as an instance variable.

Can anyone help or point me at a relevant tutorial?

Many thanks in advance.
B
5
S
2
Posts: 53
Reputation: 792

Post » Tue Sep 02, 2014 12:56 am

Here's one approach

System > Every Choose(1.0,2.0,3.0) > Sprite >Set Bullet Speed to choose(100,150,200)

The sprite is the actual bullet. Choose works well but, you could use Random and replace "System" with the conditions that you want. In this example we're also changing the speed of the bullet.

Hope this helps.
Image
B
75
S
23
G
3
Posts: 673
Reputation: 9,283

Post » Tue Sep 02, 2014 5:42 am

Ah, sorry, I meant the delay before they fire their next projectile, not the speed of the projectile.

At the moment I have something like this:

Enemy > Has line of sight
System > Every Random(1,5) Seconds >>> Enemy > Fire Projectile

The problem is that I can't seem to get each separate enemy instance to fire at a different random rate.
B
5
S
2
Posts: 53
Reputation: 792

Post » Tue Sep 02, 2014 10:08 am

@else

You could use the Timer behaviour for each enemy

RandomFireRate.capx
You do not have the required permissions to view the files attached to this post.
Find all the Construct 2 games that were on Steam Greenlight here
B
33
S
9
G
7
Posts: 451
Reputation: 6,782

Post » Tue Sep 02, 2014 4:58 pm

Ah, thanks so much! That looks perfect.
B
5
S
2
Posts: 53
Reputation: 792


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 4 guests