How do I have random objects appear (as projectiles)?

Get help using Construct 2

Post » Wed May 18, 2016 10:05 pm

Well, just looking for a way on how to get/use randomizers/RNG for Construct 2. In my case, I want a enemy to shoot a common projectile, but say, every 1 outta 7 shots, the enemy will shoot a different projectile.

Didn't see any actions/behavoir blocks for RNG...
B
13
S
1
Posts: 62
Reputation: 717

Post » Wed May 18, 2016 11:58 pm

You use variables with event actions.
On your shooter sprite put an instance variable.. say enemyShot=0
Now prior to or in your shoot event initialize variable using action set variable enemyShot=random(0,6), or enemyShot=(choose1,2,3,4,5,6)
Then use System compare instance variable and = 1 then action whatever, = 2, etc.. or in your example enemyShot<=5 regular shot >=6 special shot. (0 = 1.. so 1-7 is actually 0-6 in Construct2)
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
65
S
17
G
8
Posts: 636
Reputation: 9,333

Post » Sat May 21, 2016 6:27 pm

chrisinfinger wrote:You use variables with event actions.
On your shooter sprite put an instance variable.. say enemyShot=0
Now prior to or in your shoot event initialize variable using action set variable enemyShot=random(0,6), or enemyShot=(choose1,2,3,4,5,6)
Then use System compare instance variable and = 1 then action whatever, = 2, etc.. or in your example enemyShot<=5 regular shot >=6 special shot. (0 = 1.. so 1-7 is actually 0-6 in Construct2)



I will try that out, thanks...let you know if it works, ;) Also, I'm using the Turrent behavior to fire the projectiles; not sure if that will affect anything...
B
13
S
1
Posts: 62
Reputation: 717

Post » Sat May 21, 2016 10:50 pm

You may have to use the turrent built in actions to change its projectile type based on your variable value would be all I would think.
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
65
S
17
G
8
Posts: 636
Reputation: 9,333


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 1 guest