How do I prevent power up spawning near player.

Get help using Construct 2

Post » Thu Jan 15, 2015 3:00 pm

Hi guys,

I'm making this game that has powerups in it. It works great, but the problem is that sometimes the powerups spawn directly under my player. Since i have a power up that kills the player, i don't want this. The game is a platform game, with max x=1920. Can somebody help me make sure that the powerups spawn like 50 pixels away from my player. This is how my powerups now look like.

powerupspawn = 14 ---> create object (powerup) on layer 1 at (random(0, 1920), 850)

Can anyone help me? I read some other posts but i really didn't get how i should do this. It is also hard to test, because it doesn't happen frequently. So really need help. Game is almost ready to publish!

Thanks!
B
7
S
2
G
1
Posts: 77
Reputation: 727

Post » Thu Jan 15, 2015 3:03 pm

From what I understand of this event you could try adding a second event before the event that kills your player which would be something like
powerup overlapping player - set position (power up) to player.x +50
that might work you just have to make sure this even is read before the kill event or it will still kill your nplayer
Image
B
13
S
3
Posts: 18
Reputation: 1,152

Post » Thu Jan 15, 2015 3:12 pm

I guess at the moment it is spawned a overlap or collision would get triggered so you either add some timeout to the powerup or get a coordinate that's far enough away to begin with...

Guess something like this could work:
Image

Every 1 seconds is, of course, your event for powerup spawning - and if the random number is too close it gets spawned again until it's far enough away.
B
19
S
6
G
6
Posts: 1,101
Reputation: 5,646

Post » Thu Jan 15, 2015 3:53 pm

Somebody wrote:I guess at the moment it is spawned a overlap or collision would get triggered so you either add some timeout to the powerup or get a coordinate that's far enough away to begin with...

Guess something like this could work:
Image

Every 1 seconds is, of course, your event for powerup spawning - and if the random number is too close it gets spawned again until it's far enough away.


thanks, I will give that a try.
B
7
S
2
G
1
Posts: 77
Reputation: 727


Return to How do I....?

Who is online

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