0 Favourites

[Solved] "Random" Bug

  • Hello there, before we begin:

    Windows 7 Ultimate

    32-bit Operating System

    Intel(R) Celeron(R) CPU E1400 2.00 GHz

    2.00 GB RAM (Memory)

    Display: NVIDEA GeForce GT 430

    I added a variable to a sprite (my enemy in the game) called "BulletChoice" and it starts off at 0. in the events I added an event that says:

    * If enemy.BulletChoice = 0 Then:

    * - Set enemy.BulletChoice To ("Random(1, 2)")

    The combinations I've tried:

    Random(1, 2)

    Random(3)

    Random(0, 2)

    Random(0, 3)

    Random(1, 3)

    Random(1, 2)

    Random(2)

    I'm tyying to get the value to choose 1 or 2 (later there will be more) but It doesn't choose any of those numbers it seems, I really don't know what happens there? :S

  • You may want to try int(random(1,2)) which results will be either 1 or 2.

    Without the int(), your result is probably a float.

    If this is still not what you want/doesn't work as intended, can you post a capx showing the problem ?

    Also in the first line you write ("Random(1,2)"), did you write it like that in C2 too ?

    The ("") might indicate a string, which is not the correct variable type apparently and is not necessary.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • You may want to try int(random(1,2)) which results will be either 1 or 2.

    Without the int(), your result is probably a float.

    If this is still not what you want/doesn't work as intended, can you post a capx showing the problem ?

    Also in the first line you write ("Random(1,2)"), did you write it like that in C2 too ?

    The ("") might indicate a string, which is not the correct variable type apparently and is not necessary.

    That worked like a charm, Thanks very much for that Kyatric!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
90 77,102
leonhard's avatar
leonhard
Unread hot topic
0 Favourites
random bugs and suggestions
90 4,517
Tom's avatar
Tom Construct Team Founder
Unread hot topic
71 8,592
massivemonster's avatar
massivemonster