Spawn an object randomly at specific position

Get help using Construct 2

Post » Fri Aug 03, 2012 5:09 pm

So far this community has been awesome! I am new to construct 2 and so far I love it. I have a question, I want enemy ships to spawn at specific locations on the screen how can I do this? also after awhile gradually increase their speed
B
4
Posts: 15
Reputation: 355

Post » Fri Aug 03, 2012 5:15 pm

Depending on when you want to spawn them here is a quick example:

System - Every X Seconds
System - Create Object (Ship) on Layer Z at X,Y      

Edit:

Oops forgot about the second part. You can use the same as above for increasing their speed. Assuming they have a Bullet behaivor:

System - Every X Seconds
System - Ship -> Set Speed -> (Ship.Bullet.Speed + X)                  Acissathar2012-08-03 17:26:35
B
17
S
4
G
8
Posts: 23
Reputation: 4,886

Post » Sat Aug 04, 2012 12:06 am

is it possible to make it random rather than a set time. Like is it possible to change it every X seconds every time it spawns
B
4
Posts: 15
Reputation: 355

Post » Sat Aug 04, 2012 3:14 am

Yep, for the amount of seconds just use floor(random(x,y)) in the dialog box, with X being the minimum amount and Y being the maximum.
B
17
S
4
G
8
Posts: 23
Reputation: 4,886

Post » Sat Aug 04, 2012 4:32 am

You could also to it at specific intervals but randomly cancel some out.
Roll a random number from 1-10 every few second.
If the number is less than 1 than spawn enemies :p
B
36
S
10
G
6
Posts: 948
Reputation: 11,101

Post » Sat Aug 04, 2012 4:34 am

To gradually increase the speed you can either start checking for less than 2, than 3. Though you'd be increasing the frequency rather than speed. It works similarly to the player though. I wouldn't increase the speed through generating numbers more frequently to not make too many events run too much.
B
36
S
10
G
6
Posts: 948
Reputation: 11,101

Post » Sat Aug 04, 2012 4:30 pm

[QUOTE=Acissathar] Yep, for the amount of seconds just use floor(random(x,y)) in the dialog box, with X being the minimum amount and Y being the maximum.[/QUOTE]
how do u get floor?
B
4
Posts: 15
Reputation: 355

Post » Sat Aug 04, 2012 4:31 pm

[QUOTE=Rory] You could also to it at specific intervals but randomly cancel some out.
Roll a random number from 1-10 every few second.
If the number is less than 1 than spawn enemies :p[/QUOTE]
How do u roll a random number suorry for double post
B
4
Posts: 15
Reputation: 355

Post » Sat Aug 04, 2012 6:34 pm

[QUOTE=Sail338r] [QUOTE=Acissathar] Yep, for the amount of seconds just use floor(random(x,y)) in the dialog box, with X being the minimum amount and Y being the maximum.[/QUOTE]
how do u get floor?[/QUOTE]

The Random function grabs a decimal number from X and Y not whole values. Floor rounds that number down to a whole number to make things easier to work with.
B
17
S
4
G
8
Posts: 23
Reputation: 4,886

Post » Sun Aug 05, 2012 3:10 pm

Where do u find random or floor?
B
4
Posts: 15
Reputation: 355

Next

Return to How do I....?

Who is online

Users browsing this forum: adi pratama, twg and 28 guests