How do I Get enemies to shoot randomly not at the same time

Get help using Construct 2

Post » Fri Nov 14, 2014 4:23 am

All enemies are assigned a bullet behavioir. I have it set so that every random 2-5 seconds the enemies change bullet angle and speed, but instead of each one using their own random value, they all change angle and direction at the same time. Ive had problems with this trying to get enemies to shooot at different times, but I can't figure out how to give each enemy a random timer. I also tried assigning each enemy a timer, and used For Each statements, but nothing works. Any ideas?
B
35
S
5
Posts: 411
Reputation: 3,406

Post » Fri Nov 14, 2014 4:44 am

There is a timer behaviour you could attach to the object.

However, you also mention they all have to change at the same time then you could either

1. set a variable which is subtracted from each tick e.g.., MyTime subtract by (10*dt)
2. set a timer to a dummy object and when that fires loop through all your oibjects and set the new angles etc
B
37
S
9
G
5
Posts: 437
Reputation: 6,094

Post » Fri Nov 14, 2014 4:56 am

I do want them to all act differently, and not off of the same timer. hmmmm i tried having a timer object to the character, but it didnt work. Maybe i did it wrong
B
35
S
5
Posts: 411
Reputation: 3,406

Post » Fri Nov 14, 2014 5:52 am

I would simply set a instance variable for each object and when it is less than zero do the action and reset the variable. Each tick or every 0.5 seconds reduce the variable with an amount that is appropriate. i.e., either dt or a fixed time
B
37
S
9
G
5
Posts: 437
Reputation: 6,094


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 6 guests