How do I set a random spawning between two x coordinates?

0 favourites
  • 5 posts
From the Asset Store
Footsteps SFX Two contains 450 sounds of steps and jumps on different surfaces.
  • I am making a music bar, and I want to set notes to randomly span different positions on the bar, but I want the note to stay in the correct place. I have set the correct y position, but I want it to be able to spawn anywhere between the beginning of the bar and the end (on the x scale), but not anywhere else on the view-able screen. Any ideas?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Create object note on layer at x=random(music_bar.x + music_bar.x/2 , music_bar.x - music_bar.x/2), y=(the value that you have)

  • I have 7 notes, and I only want one to show up on the screen at a time. I think I can do that using a family, but it won't let me enter the formula. Also, how would I make a family - spawner that spawned the different notes at different y-coordinates? I think the formula would be a little different for that, right?

  • Families are only available in the personal or business licence and not in the free version Im afraid.

    Make a variable that checks if the note is on screen, for example:

    0 - for no, 1 for yes (or you can set up a boolean under object instance varaibles, in the left panel once you select a sprite)


    If Note_Spawned=0 ---> spawn object note at x,y (as in the post above), set variable Note_Spawned=1

    If note is not on screen ---> set Note_spawned=0

    (this is to terminate the note, and once terminated allow another note to be spawned)

  • I do have the personal license, it just doesn't show up on Scirra because I bought it through Steam. I tried the formula, but no matter how I enter it it keeps telling me something is wrong. Mostly it doesn't like the "," in the middle of the x formula...

    I tried it exactly as shown above.

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