How do I prevent power up spawning near player.

0 favourites
  • 4 posts
From the Asset Store
75 power-up sound effects; bonus and notification sounds, fanfares, harp glissandi, stabs, clock ticks, etc.
  • 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!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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

  • 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:

    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.

  • 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:

    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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)