random(x) glitch

0 favourites
  • 6 posts
From the Asset Store
Tweakable and easy to use effects for your projects.
  • the random(x) event has been a bit quirky...not sure if this a bug or just a random anomaly

    random(x) works in 1 part of my code but doesn't work in another

    when i open a new doc and enter the same code it works fine...is this a problem with the current project or is it just a very "random" glitch

    ???

    i'd rather not create an entirely new project just to clear up 2 lines (albeit vital) of code

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Well if I asked you to move random(x) feet, what exactly would that mean to you?

    The reason I ask is because at this point it means the same as random(a), or random(n), or random(z) to me.

    Good chance that it would mean the same in C2.

  • qwiktags: post your capx please.

    We can't guess out of the blue what the quirks or glitches are.

    Also think to provide the required infos as asked in how to report a bug.

  • Sorry guys. I do apologize for my oversite (it was a wee bit early/late when I made the post)

    Here is the quick and dirty version of what is going on

    (this works just fine)

    global variable = 0

    global variable2 = 0

    System -> every random(5)+2 seconds --> spawner1...spawn sprite

                                                                           set sprite.Y to random (300)+20

                                                                           set global variable2 = 1

                                                                           do more stuff..

    (this part gets glitchy)**

    System -> every random(15)+5 sec --> spawner2 spawn sprite2

                 -> global variable2=1                 system set global variable to random(3)+1 **(this part does not register)

                                                                    set sprite2.Y to random (300)+20 (works fine)

                                                                    ( the remaining code in this block works fine)...

                                                                    system set global variable2 =0

    system -> global variable = 1 --> spwaner3 spawn sprite3

                                                           do stuff

    (nothing happens in this block because there is no value generated for global variable which could be 1,2 or 3)

    I hope this helps, if not I'll post the capx later on today

  • At global variable2 =1 => system set global variable to int(random(1,3)) should do the trick.

    random() returns a float. By setting a range and making it an int(eger) , you are sure random will return either 1, 2 or 3.

    Next time though, post directly the capx, it will be easier to answer you.

  • Thanx...I'll give it a shot

    I also tried moving the random(3)+1 line to block 3 and the result was the same (nothing registers)

    I'll post the capx anyway later today

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