How do I make bullet fire in random time by many shooter

Get help using Construct 2

Post » Wed Oct 19, 2016 2:41 pm

i have a bullet(just a single sprite) used by many villains shoooting my player. now, in my condition they fire up in every 2 seconds(so all the villains shoot bullet @same time). now, how do i make the bullet of each villain fire in random? im thinking about using different bullet sprite for every viillain so i can control how much time they should fire per x second in random :? :shock: but i think its a pain in the a$$ if i do it 1 by 1. any suggestions? :D :D :D
B
4
Posts: 7
Reputation: 216

Post » Wed Oct 19, 2016 2:53 pm

You can have random 'reload' and firing times by doing this:
Add the Timer behavior to your villains (enemies)
On start of Layout:
---> Enemy: Start Timer "fire" for random(1,3) (regular)

On Timer "fire":
---> System: Create object "bullet" on layer 0 at (enemy.X, enemy.Y)

This will make them shoot a bullet every 1 to 3 seconds.

I hope this helps! :)
Image
B
5
S
3
Posts: 193
Reputation: 1,063

Post » Wed Oct 19, 2016 4:39 pm

You can also make a condition like this:

Code: Select all
- Every [random(0.5,2)] seconds
- For each Villain
          --> Shoot bullet


This will fire each Villain's gun at random times.
The "for each" causes a random time to be created for every instance of a villain again.

If you want every villain to shoot exactly every 2 second, but at different times,
choose this:
Code: Select all
- Every 2 seconds
- For each Villain
        --> Wait [random(0.5,2)] seconds
        --> Shoot bullet
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
B
27
S
11
G
8
Posts: 528
Reputation: 7,091

Post » Thu Oct 20, 2016 4:08 am

aquadijoib wrote:You can have random 'reload' and firing times by doing this:
Add the Timer behavior to your villains (enemies)
On start of Layout:
---> Enemy: Start Timer "fire" for random(1,3) (regular)

On Timer "fire":
---> System: Create object "bullet" on layer 0 at (enemy.X, enemy.Y)

This will make them shoot a bullet every 1 to 3 seconds.

I hope this helps! :)
-> set object time scale?


- How to set timer? :?: :|
B
4
Posts: 7
Reputation: 216

Post » Thu Oct 20, 2016 4:41 am

randomly wrote:You can also make a condition like this:

Code: Select all
- Every [random(0.5,2)] seconds
- For each Villain
          --> Shoot bullet


This will fire each Villain's gun at random times.
The "for each" causes a random time to be created for every instance of a villain again.

If you want every villain to shoot exactly every 2 second, but at different times,
choose this:
Code: Select all
- Every 2 seconds
- For each Villain
        --> Wait [random(0.5,2)] seconds
        --> Shoot bullet



is
Code: Select all
Every [random(0.5,2)] seconds
an event with blank action and
Code: Select all
For each Villain
an event with
Code: Select all
 Shoot bullet
action :?: :?:
B
4
Posts: 7
Reputation: 216

Post » Thu Oct 20, 2016 4:46 am

aquadijoib wrote:You can have random 'reload' and firing times by doing this:
Add the Timer behavior to your villains (enemies)
On start of Layout:
---> Enemy: Start Timer "fire" for random(1,3) (regular)

On Timer "fire":
---> System: Create object "bullet" on layer 0 at (enemy.X, enemy.Y)

This will make them shoot a bullet every 1 to 3 seconds.

I hope this helps! :)



I re read your comment! iunderstand now its working! thanks :) :) :)
B
4
Posts: 7
Reputation: 216


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 6 guests