How to randomly select -50 OR 50 (but NOT between)

0 favourites
  • 4 posts
From the Asset Store
You think you can guess the character’s name?! Then let’s see how smart you are!
  • When a particular action happens in my game, I want the computer to randomly select either -50 or 50. However, I do not want the computer to select any figures between -50 and 50.

    I know that to allow the computer to randomly select any number between -50 or 50 I would use the following command: random(-50,50)

    However, in this particular instance, I only want the computer to randomly pick either -50 or 50. How exactly do I do that?

    Thank you in advance

  • choose(-50,50)

  • wow! Thank you for your very prompt response. That certainly answers my question. However, something still confuses me:

    I used that exact command that you suggested: choose(-55, 55)

    Oddly however, when the bottle is hit with the ball, the bottle does not always fall to the left or to the right. Sometimes, the bottle Barely moves at all to the left or to the right. It is almost like the computer thinks it is using the random command and not necessarily selecting -55 OR 55.

    Any idea what could be causing this issue? Again, I absolutely used the command you suggested: choose(-55, 55) for the "apply physics Force" for the "force X". I intentionally left the force for Y at zero.

    Any ideas?

    PS: I changed the choose(-55, 55) instead just to a single number and once I changed it to a single number, the bottle fell over every single instance without exception. However, once I returned back to using that choose command, it seems that the computer would get confused and randomly barely move the bottle at all. Therefore, perhaps, that choose command might not be working properly?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The forum is refusing to let me attach for some reason. I tried a quick experiment, and it was working fine. Maybe post an example of what is failing.

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