[SOLVED] How do I Create rare event?

0 favourites
  • 3 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • Hi in my game i need to achieve this, during the game i need to show a special artifact who appears just once, but that event need to be created randomly at any moment and in any level.

    how can i achieve that??


  • Hey imothep85, :)

    You can use a global variable to keep track of whether the item has been created yet, and then randomly try to create it each time a new level is started, but only if it hasn't been created yet.


    Create a global variable named "isRareItemSpawned" with an initial value of "0".

    "0" means "not yet".

    "1" means it has been spawned.

    Use an event like the one below to spawn the item:


    At the beginning of a new level,

    If isRareItemSpawned = 0,

    Compare two values, is "random( 0 , 100 )" less or equal to "2". (don't use quotes)


    Spawn the item somewhere in the level.

    The "Compare two values" condition can be found in the System object.

    The "random( 0 , 100 )" expression will create a random number between 0 and 100, so it has a 2% chance of being less than 2. That's 1 out of 50. If you want to make the item even more rare, you can instead use 1, for 1%, or 0.5 for an even smaller chance.

    Hope that helps out. :)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks again for that great explanation :D

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