Looking for expression / solution Bullet behavior

Get help using Construct 2

» Tue Mar 07, 2017 10:59 am

Black dot every 1 second should spawn one blue arrow with bullet behavior
Arrow on created/spawned should randomly choose direction to fly in the hole
Black dot should NOT be rotated

What i should do ?
B
26
S
8
Posts: 229
Reputation: 2,228

» Tue Mar 07, 2017 11:45 am

@IGDev

Assuming you've already given the Blue Arrow the Bullet behaviour, add these two events:

System: Every 1 second -> Black Dot: Spawn another object - Blue Arrow

Blue Arrow: On created -> Set angle to random(360)
Find all the Construct 2 games that were on Steam Greenlight here
B
42
S
11
G
7
Posts: 513
Reputation: 7,355

» Tue Mar 07, 2017 11:47 am

OddConfection wrote:@IGDev

Assuming you've already given the Blue Arrow the Bullet behaviour, add these two events:

System: Every 1 second -> Black Dot: Spawn another object - Blue Arrow

Blue Arrow: On created -> Set angle to random(360)

Set random to 360 is wrong because arrow will multiple times miss hole
arrow on created should randomly sethis angle to holes position

when i use SET angle(self.X, self.Y, hole.X, hole.Y)
arrow go always to nearest hole and that is wrong
B
26
S
8
Posts: 229
Reputation: 2,228

» Tue Mar 07, 2017 11:50 am

IGDev wrote:when i use SET angle(self.X, self.Y, hole.X, hole.Y)
arrow go always to nearest hole and that is wrong

Pick a random hole!

[event] Blue Arrow: On Created
[sub-event] System: Pick random instance (hole) -> Blue Arrow: Set angle to angle(self.X, self.Y, hole.X, hole.Y)
Last edited by OddConfection on Tue Mar 07, 2017 11:56 am, edited 3 times in total.
Find all the Construct 2 games that were on Steam Greenlight here
B
42
S
11
G
7
Posts: 513
Reputation: 7,355

» Tue Mar 07, 2017 11:50 am

IGDEV try this

1 create Global variable Spawn_Time = 2
2 system every random (Spawn_Time) seconds ACTION BlackDot create bluearrow
3 set bullet speed to ACTION random(220,400)
4 set angle of motions ACTION random (360) degree
B
269
S
52
G
16
Posts: 2,045
Reputation: 44,128

» Tue Mar 07, 2017 11:55 am

OddConfection wrote:
IGDev wrote:when i use SET angle(self.X, self.Y, hole.X, hole.Y)
arrow go always to nearest hole and that is wrong

Pick a random hole!

[event] Blue Arrow: On Created
[sub-event] System: Pick random instance (hole) -> Blue Arrow: Set angle(self.X, self.Y, hole.X, hole.Y)

WORKS ! thanks
B
26
S
8
Posts: 229
Reputation: 2,228